-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fold_change for interactions between factors
- Loading branch information
Showing
5 changed files
with
63 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,3 +13,4 @@ inst/doc | |
structtoolbox.Rproj | ||
*.Rproj | ||
*.Rproj | ||
*.tiff |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
#' fold change for interactions class | ||
#' | ||
#' calculates fold change between groups for all factors and interactions | ||
#' | ||
#' @import struct | ||
#' @import stats | ||
#' @export fold_change_int | ||
fold_change_int<-setClass( | ||
"fold_change_int", | ||
contains=c('method','fold_change'), | ||
) | ||
|
||
#' @export | ||
setMethod(f="method.apply", | ||
signature=c("fold_change_int",'dataset'), | ||
definition=function(M,D) | ||
{ | ||
|
||
## apply fold change between all pairwise combinations of levels of all factors | ||
# combinations of factors | ||
FF=structToolbox:::full_fact(M$factor_name) | ||
FF=apply(FF,1,function(x) M$factor_name[x==1]) | ||
FF=FF[-1] | ||
|
||
# remove single factor comparisons | ||
L=lapply(FF,length) | ||
w=which(L==1) | ||
FF=FF[-w] | ||
|
||
# for each combination create an interaction factor and compute fold-change on that factor | ||
for (k in 1:length(FF)) { | ||
|
||
D$sample_meta$interaction=interaction(D$sample_meta[,FF[[k]]]) | ||
FC=fold_change(alpha=M$alpha,paired=FALSE,sample_name='NA',factor_name='interaction') | ||
FC=method.apply(FC,D) | ||
if (k==1) { | ||
M$fold_change=FC$fold_change | ||
M$upper_ci=FC$upper_ci | ||
M$lower_ci=FC$lower_ci | ||
} else { | ||
# bind the results tables together | ||
M$fold_change=cbind(M$fold_change,FC$fold_change) | ||
M$upper_ci=cbind(M$upper_ci,FC$upper_ci) | ||
M$lower_ci=cbind(M$lower_ci,FC$lower_ci) | ||
} | ||
} | ||
|
||
return(M) | ||
} | ||
) |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.