Commit 6870d0c6 authored by Holger Brandl's avatar Holger Brandl

revision set intersection helpers

parent 8f5d78d2
......@@ -161,13 +161,13 @@ s1_eq_s2 <- function(deData, sample_1, sample_2, gene_background=all_genes){
diff_intersect <- function(deData, sample_1, sample_twoes, .intersect_method, ...){
## Example: diff_intersect(degs, "VZ", c("ISVZ", "OSVZ", "CP"), s1_gt_s2)
# rec_intersect sample_twoes = list(...)
# list_acc sample_twoes = list(...)
# sample_twoes <- list(); sample_1="VZ"
#browser()
rec_intersect <- .intersect_method(deData, sample_1, sample_twoes[1], ...)$gene_id
list_acc <- .intersect_method(deData, sample_1, sample_twoes[1], ...)$gene_id
for (i in 2:length(sample_twoes)) {
rec_intersect <- intersect(rec_intersect, .intersect_method(deData, sample_1, sample_twoes[i], ...)$gene_id)
list_acc <- intersect(list_acc, .intersect_method(deData, sample_1, sample_twoes[i], ...)$gene_id)
}
......@@ -187,9 +187,9 @@ diff_intersect <- function(deData, sample_1, sample_twoes, .intersect_method, ..
## todo maybe it's better to return an empty table here and use factors to indicate the level without genes
## to make sure that we don't loose an empty list, use NA as placeholder
if(length(rec_intersect)==0) rec_intersect=NA;
if(length(list_acc)==0) list_acc=NA;
data_frame(gene_id=rec_intersect, list_id=list_id);
data_frame(gene_id=list_acc, list_id=list_id);
}
......@@ -202,18 +202,26 @@ diff_intersect <- function(deData, sample_1, sample_twoes, .intersect_method, ..
## varargs: http://stackoverflow.com/questions/3057341/how-to-use-rs-ellipsis-feature-when-writing-your-own-function
## DEPRECATED
rintersect <- function(...){
intersect_all <- function(...){
LDF <- list(...)
rintersect.list(LDF)
list_acc <- LDF[[1]]
for (i in 2:length(LDF)) {
list_acc <- intersect(list_acc, LDF[[i]])
}
list_acc
}
union_all <- function(...){
LDF <- list(...)
rintersect.list <- function(LDF){
rec_intersect <- LDF[[1]]
list_acc <- LDF[[1]]
LDF <- list(...)
for (i in 2:length(LDF)) {
rec_intersect <- intersect(rec_intersect, LDF[[i]])
list_acc <- union(list_acc, LDF[[i]])
}
rec_intersect
list_acc
}
Markdown is supported
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