From 771508472a157f5bae6dfc7b477af55a692d8416 Mon Sep 17 00:00:00 2001 From: Jincheng Wang Date: Fri, 31 Jan 2020 12:29:21 -0500 Subject: [PATCH 1/4] Remove the request for writing to harddrive --- R/FEAST.R | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/R/FEAST.R b/R/FEAST.R index 149be09..1782291 100644 --- a/R/FEAST.R +++ b/R/FEAST.R @@ -41,8 +41,7 @@ #' } #' #' @export -FEAST <- function(C, metadata, EM_iterations = 1000, COVERAGE = NULL ,different_sources_flag, - dir_path, outfile){ +FEAST <- function(C, metadata, EM_iterations = 1000, COVERAGE = NULL ,different_sources_flag, dir_path = NULL, outfile = NULL){ ###1. Parse metadata and check it has the correct hearer (i.e., Env, SourceSink, id) if(sum(colnames(metadata)=='Env')==0) stop("The metadata file must contain an 'Env' column naming the source environment for each sample.") @@ -143,9 +142,11 @@ FEAST <- function(C, metadata, EM_iterations = 1000, COVERAGE = NULL ,different_ colnames(proportions_mat) <- c(envs_sources, "Unknown") rownames(proportions_mat) <- envs_sink # proportions_mat[is.na(proportions_mat)] <- 999 + if(!is.null(dir_path)){ + setwd(dir_path) + write.table(proportions_mat, file = paste0(outfile,"_source_contributions_matrix.txt"), sep = "\t") + } - setwd(dir_path) - write.table(proportions_mat, file = paste0(outfile,"_source_contributions_matrix.txt"), sep = "\t") return(proportions_mat) } From d7ddd8dcda6235c3f8efe8135bfce62863a28c99 Mon Sep 17 00:00:00 2001 From: Jincheng Wang Date: Fri, 31 Jan 2020 13:59:29 -0500 Subject: [PATCH 2/4] Fix the problem with unknown_initialize_1 --- R/Infer_LatentVariables.R | 1 - 1 file changed, 1 deletion(-) diff --git a/R/Infer_LatentVariables.R b/R/Infer_LatentVariables.R index 82943c7..6f26eae 100644 --- a/R/Infer_LatentVariables.R +++ b/R/Infer_LatentVariables.R @@ -129,7 +129,6 @@ unknown_initialize_1 <- function(sources, sink, n_sources){ sources_sum <- apply(sources, 2 ,sum) - unknown_source <- c() if(n_sources > 1){ From 342b9c42dda51b28bf1a74d8341d1a24311ffc0c Mon Sep 17 00:00:00 2001 From: Jincheng Wang Date: Fri, 9 Oct 2020 16:22:44 -0400 Subject: [PATCH 3/4] Small fix 1 in FEAST_rarefy Fix the code in matrix checking so that it won't generate confusing warning if class(x) return more than 1 value --- R/utils.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/utils.R b/R/utils.R index d346034..1228cfc 100644 --- a/R/utils.R +++ b/R/utils.R @@ -44,7 +44,7 @@ FEAST_rarefy <- function(x,maxdepth){ if(is.null(maxdepth)) return(x) - if(!is.element(class(x), c('matrix', 'data.frame','array'))) + if(!any(is.element(class(x), c('matrix', 'data.frame','array')))) x <- matrix(x,nrow=nrow(x)) nr <- nrow(x) nc <- ncol(x) From a6b44115578b221e0cc6f1d5bf528ec6c67f693f Mon Sep 17 00:00:00 2001 From: Jincheng Wang Date: Thu, 15 Oct 2020 16:02:16 -0400 Subject: [PATCH 4/4] edit the unkown_intialize_1 function --- R/Infer_LatentVariables.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/Infer_LatentVariables.R b/R/Infer_LatentVariables.R index 6f26eae..30f3001 100644 --- a/R/Infer_LatentVariables.R +++ b/R/Infer_LatentVariables.R @@ -168,7 +168,7 @@ unknown_initialize_1 <- function(sources, sink, n_sources){ if(length(ind_cor_all) > 1){ cor_abundance <- round(apply(sources[,ind_cor_all], 2, min)/2) #take the min abundnace of the 'cor' - unknown_source[ind_cor_all] <- 0 + unknown_source[ind_cor_all] <- cor_abundance }