sorter {BAMSE}R Documentation

~~function to do ... ~~

Description

~~ A concise (1-5 lines) description of what the function does. ~~

Usage

sorter(visit1, snp1, k = rep(T, dim(visit1)[1]), iter, write = F, SNPs, file = NA, only = F, log = F, strict = T)

Arguments

visit1 ~~Describe visit1 here~~
snp1 ~~Describe snp1 here~~
k ~~Describe k here~~
iter ~~Describe iter here~~
write ~~Describe write here~~
SNPs ~~Describe SNPs here~~
file ~~Describe file here~~
only ~~Describe only here~~
log ~~Describe log here~~
strict strict =T

Details

~~ If necessary, more details than the description above ~~

Value

~Describe the value returned If it is a LIST, use

comp1 Description of 'comp1'
comp2 Description of 'comp2'

...

Warning

....

Note

~~further notes~~

~Make other sections like Warning with section{Warning }{....} ~

Author(s)

~~who you are~~

References

~put references to the literature/web site here ~

See Also

~~objects to See Also as help, ~~~

Examples

##---- Should be DIRECTLY executable !! ----
##-- ==>  Define data, use random,
##--    or do  help(data=index)  for the standard data sets.

## The function is currently defined as
function(visit1,snp1,k=rep(T,dim(visit1)[1]),iter,write=F,SNPs,file=NA,only=F,log=F){
visit1<-visit1[k,]
sampled1<-ifelse(!is.na(visit1[,c(snp1)]),1,0)
if(length(c(snp1))>1){
sam<-apply(sampled1,2,mean)
SNP1<-c(snp1)[order(sam,decreasing=T)[1]]
  }
else{
SNP1<-c(snp1)
  }

keep<-ifelse(!is.na(visit1[,SNP1]),T,F)
if(sum(keep)==0){
k[k]<-ifelse(keep,T,F)
return(c(post=0,SNP1=NA,geno=NA,k))
  }
geno<-as.integer(names(table(visit1[keep,SNP1]))[order(table(visit1[keep,SNP1])[],decreasing=T)[1]])
keep1<-ifelse(visit1[,SNP1]==geno&!is.na(visit1[,SNP1]),TRUE,FALSE)
#print(table(keep1))

post<-table(keep1)["TRUE"]/iter
#cat("SNP",SNP1," geno: ",geno," frac: ",table(keep1)[2]/sum(length(k))," post: ",post," ")
#cat(mean," ",mean05,"-",mean95," #: ",ind05,"-",ind95,"\n")
if(write){

vis_temp<-visit1[keep1,]
snp1<-snp1[order(sam,decreasing=T)[2:length(snp1)]]
keep.only<-ifelse(apply(is.na(vis_temp[,snp1]),1,sum)==length(snp1),T,F)
post.only<-table(keep.only)["TRUE"]/iter

post.strict<-dim(table(vis_temp[,"iter"]))/iter
vis_temp<-vis_temp[keep.only,]
post.only.strict<-dim(table(vis_temp[,"iter"]))/iter

mean<-mean(visit1[keep1,"adj_mean"])
mean05<-sort(visit1[keep1,"adj_mean"])[max(0.05*dim(visit1[keep1,])[1],1)]
mean95<-sort(visit1[keep1,"adj_mean"])[max(0.95*dim(visit1[keep1,])[1],1)]

if(log){
mean<-round(exp(mean),2)
mean05<-round(exp(mean05),2)
mean95<-round(exp(mean95),2)
  }
else{
mean<-round((mean),2)
mean05<-round((mean05),2)
mean95<-round((mean95),2)
  }
ind05<-sort(visit1[keep1,"nr"])[max(0.05*dim(visit1[keep1,])[1],1)]
ind95<-sort(visit1[keep1,"nr"])[max(0.95*dim(visit1[keep1,])[1],1)]

SNPs[SNP1]<-geno
variable<-paste(ind05,"-",ind95," ",mean,"(",mean05,"-",mean95,") ",post," ",post.only," ",post.strict," ",post.only.strict,sep="")
write.table(cbind(t(SNPs),variable),file=file,append=T,quote=F,row.names=F,col.names=F)
  }

k[k]<-ifelse(keep1,T,F)
return(c(post,SNP1,geno,k))
  }

[Package BAMSE version 2.0 Index]