Skip to main content

Topic: Changing or adding minFrac after processing (Read 2649 times) previous topic - next topic

  • hpbenton
  • [*][*][*]
Changing or adding minFrac after processing
So you're finished with processing but you want to change minFrac. There must be an automated way to do this other than hand picking in excel!
You used the group.nearest method and would really like to get rid of some  of the non reproducible groups. How can I do this before printing the diffreport.

Using the following function below and assuming that you still have an xcmsSet object saved or in the R console its easy. Example code follows using the faahko dataset.
Code: [Select]
post.minFrac<-function(object, minFrac=0.5){
ix.minFrac<-sapply(1:length(unique(sampclass(object))), function(x, object, mf){
idx<-which(meta[,levels(sampclass(object))[x]] >= mf*length(which(levels(sampclass(object))[x] == sampclass(object)) ))
}, object, minFrac)
ix.minFrac<-as.logical(apply(ix.minFrac, 1, sum))
ix<-which(ix.minFrac == TRUE)
## return(ix)

The faahKO toy dataset:

Code: [Select]
library(faahKO) ## These files do not have this problem to correct for but just for an 
cdfpath <- system.file("cdf", package = "faahKO")
cdffiles <- list.files(cdfpath, recursive = TRUE, full.names = TRUE)

gxset<-group(xset, method="nearest")
nrow(gxset@groups) == 1096 ## the number of features before minFrac

nrow(gxset@groups) == 465 ## and after minFrac !

H. Paul Benton
Scripps Research Institute
If you have an error with XCMS Online please send me the JOBID and submit an error via the XCMS Online contact page