mirror of
https://github.com/agdamsbo/daDoctoR.git
synced 2024-11-22 03:40:23 +01:00
u
This commit is contained in:
parent
ba38fa052d
commit
a8afb7df46
32
R/hwe_sum.R
32
R/hwe_sum.R
@ -9,26 +9,18 @@
|
|||||||
#' @examples
|
#' @examples
|
||||||
#' hwe_sum()
|
#' hwe_sum()
|
||||||
|
|
||||||
hwe_sum<-function(a1,a2,f){
|
hwe_sum<-function (a1, a2, f) {
|
||||||
## HWE summarising function, for several groups defined by factor f. Alleles are provided as vectors, a1 and a2.
|
require(daDoctoR)
|
||||||
|
lst <- list()
|
||||||
|
df <- data.frame(a1, a2)
|
||||||
|
|
||||||
source("https://raw.githubusercontent.com/agdamsbo/research/master/hwe_allele.R")
|
for (i in 1:length(ls <- split(df, f))) {
|
||||||
lst<-list()
|
grp <- names(ls)[i]
|
||||||
df<-data.frame(cbind(a1,a2))
|
obs <- data.frame(hwe_allele(ls[[i]][, 1], ls[[i]][,2])[[c("observed.dist")]])
|
||||||
for (i in 1:length(ls<-split(df,f))){
|
pval <- round(hwe_allele(ls[[i]][, 1], ls[[i]][, 2])[[c("p.value")]],3)
|
||||||
|
prnt <- paste0(obs[1, ], " (", obs[2, ], ")")
|
||||||
grp<-names(ls)[i]
|
names(prnt) <- names(obs)
|
||||||
|
lst <- list(lst, grp, obs.dist = obs, print = prnt,hwe.pv = pval)
|
||||||
obs<-data.frame(hwe_allele(ls[[i]][,1],ls[[i]][,2])[[c("observed.dist")]])
|
|
||||||
|
|
||||||
pval<-round(hwe_allele(ls[[i]][,1],ls[[i]][,2])[[c("p.value")]],3)
|
|
||||||
|
|
||||||
prnt<-paste0(obs[1,]," (",obs[2,],")")
|
|
||||||
|
|
||||||
names(prnt)<-names(obs)
|
|
||||||
|
|
||||||
lst<-list(lst,grp,obs.dist=obs,print=prnt,hwe.pv=pval)
|
|
||||||
}
|
}
|
||||||
|
return(lst)
|
||||||
return(lst)
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user