Skip to content
Snippets Groups Projects
Commit e5275462 authored by Zhiyu Zhao's avatar Zhiyu Zhao
Browse files

Bug fixed for fold change with empty groups when imputation is not enabled.

parent 3ee6ee14
Branches
No related merge requests found
......@@ -57,15 +57,27 @@ fold_change=function(dataList,groups,groupMeanLowerBound,logTransform) {
for (i in unique(temp$Feature)) {
featureData=temp[temp$Feature==i,]
res[[names1[1]]][i]=mean(featureData$Value[featureData$GroupID==g],na.rm=T)
res[[names1[2]]][i]=sd(featureData$Value[featureData$GroupID==g],na.rm=T)
res[[names1[3]]][i]=res[[names1[1]]][i]
if (res[[names1[3]]][i]<groupMeanLowerBound)
res[[names1[3]]][i]=groupMeanLowerBound
if (!is.nan(res[[names1[1]]][i])) { #Added on 5/16/23 for cases where the group is empty and no imputation is used.
res[[names1[2]]][i]=sd(featureData$Value[featureData$GroupID==g],na.rm=T)
res[[names1[3]]][i]=res[[names1[1]]][i]
if (res[[names1[3]]][i]<groupMeanLowerBound)
res[[names1[3]]][i]=groupMeanLowerBound
} else {
res[[names1[1]]][i]=NA
res[[names1[2]]][i]=NA
res[[names1[3]]][i]=NA
}
res[[names2[1]]][i]=mean(featureData$Value[featureData$GroupID!=g],na.rm=T)
res[[names2[2]]][i]=sd(featureData$Value[featureData$GroupID!=g],na.rm=T)
res[[names2[3]]][i]=res[[names2[1]]][i]
if (res[[names2[3]]][i]<groupMeanLowerBound)
res[[names2[3]]][i]=groupMeanLowerBound
if (!is.nan(res[[names2[1]]][i])) { #Added on 5/16/23 for cases where the group is empty and no imputation is used.
res[[names2[2]]][i]=sd(featureData$Value[featureData$GroupID!=g],na.rm=T)
res[[names2[3]]][i]=res[[names2[1]]][i]
if (res[[names2[3]]][i]<groupMeanLowerBound)
res[[names2[3]]][i]=groupMeanLowerBound
} else {
res[[names2[1]]][i]=NA
res[[names2[2]]][i]=NA
res[[names2[3]]][i]=NA
}
if (logTransform) {
res[[paste0('log2_',fcName)]][i]=res[[names1[3]]][i]-res[[names2[3]]][i]
res[[fcName]][i]=2^res[[paste0('log2_',fcName)]][i]
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment