计算杂合度函数calHe(配合polysat包使用)
Posted liulele
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了计算杂合度函数calHe(配合polysat包使用)相关的知识,希望对你有一定的参考价值。
calHe <- function(fre, filename = "hets.txt"){ pops = row.names(fre) loci = unique(as.matrix(as.data.frame(strsplit(names(fre), split = ".", fixed = TRUE), stringsAsFactors = FALSE))[1, ]) loci <- loci[loci != "Genomes"] hets <- array(0, dim = c(length(pops),length(loci)), dimnames = list(pops, loci)) for(P in pops){ freqs <- fre[P, ] genomes <- freqs$Genomes names(genomes) <- row.names(freqs) thesegenomes <- genomes for (L in loci) { thesefreqs <- freqs[, grep(paste("^", L, "\.", sep = ""), names(freqs)), drop = FALSE] thesefreqs <- thesefreqs[, names(thesefreqs) != paste(L, "Genomes", sep = "."), drop = FALSE] hsByPop <- apply(as.matrix(thesefreqs), 1, function(x) 1 - sum(x^2)) avgfreq <- unlist(lapply(thesefreqs, weighted.mean, w = thesegenomes)) hets[P,L] <- 1 - sum(avgfreq^2) } } hets<-data.frame(hets) hets$mean <- apply(hets,1,mean) write.table(hets, filename, sep = " ",quote = FALSE) return(hets) }
以上是关于计算杂合度函数calHe(配合polysat包使用)的主要内容,如果未能解决你的问题,请参考以下文章
python 杂合极化 - 极化基于先前在VCF文件中识别杂合调用的可能性的杂合调用。 Usefu
python使用NiBabel包加载.nii标记mask文件统计两个标注员标注的mask掩码文件的重合度有多高(对应位置的元素相同则为1,否则则为0)