Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

1 minor change and 1 critical change #13

Open
wants to merge 4 commits into
base: FEAST_beta
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions R/FEAST.R
Original file line number Diff line number Diff line change
Expand Up @@ -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.")
Expand Down Expand Up @@ -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)

}
3 changes: 1 addition & 2 deletions R/Infer_LatentVariables.R
Original file line number Diff line number Diff line change
Expand Up @@ -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){

Expand Down Expand Up @@ -169,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


}
Expand Down
2 changes: 1 addition & 1 deletion R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down