Closed gauguinP closed 1 year ago
I had same issue, but think I solved it; in the line of code below, you specify an output directory in the outfile line.
In this example, at least for me, it shows up as "demo_source_contributions_matrix.txt" when you open the folder you set as your output directory. The issue here is that this file is actually a list, not a matrix. Therefore, when you try to acquire the rowname/columnames, this will return as a NULL value, as the data format does not tell R it has rows or columns.
I remedied this by telling R that this file was indeed a matrix, not a list via the below code: FEAST_output <- as.matrix(read.table("~/FEAST/Data_files/demo_source_contributions_matrix.txt"))
Now, running the code specified by the tutorial for PlotSourceContribution spits out this:
Below is the full R Notebook from this run for reference, hope it helps (just replace any "~/FEAST/Data_files/" with your personal directory info as needed to make the code work with where you have your files stored)!
knitr::opts_chunk$set(
collapse = FALSE,
comment = "##",
highlight = TRUE,
prompt = FALSE,
results = "markup"
)
Packages <- c("Rcpp", "RcppArmadillo", "vegan", "dplyr", "reshape2", "gridExtra", "ggplot2", "ggthemes")
# install.packages(Packages)
lapply(Packages, library, character.only = TRUE)
devtools::install_github("cozygene/FEAST")
library(FEAST)
metadata <- Load_metadata(metadata_path = "~/FEAST/Data_files/metadata_example_multi.txt")
otus <- Load_CountMatrix(CountMatrix_path = "~/FEAST/Data_files/otu_example_multi.txt")
FEAST_output <- FEAST(C = otus,
COVERAGE=NULL,
metadata = metadata,
different_sources_flag = 1,
dir_path = "~/FEAST/Data_files/",
outfile="demo")
FEAST_output <- as.matrix(read.table("~/FEAST/Data_files/demo_source_contributions_matrix.txt"))
PlotSourceContribution(SinkNames = rownames(FEAST_output)[c(5:8)],
SourceNames = colnames(FEAST_output),
dir_path = "~/FEAST/Data_files/",
mixing_proportions = FEAST_output,
Plot_title = "Test_",
Same_sources_flag = 0,
N = 4)
Dear Ben, i use your code and get the same plot ,thank you for your help.
I use the metadata_example.txt and out_example.txt.After finishing the FEAST_output,i face an error in PlotSourceContribution. The code is shown below: PlotSourceContribution(SinkNames = rownames(FEAST_output)[c(6:2)], SourceNames = colnames(FEAST_output), dir_path = "D:/科研/study/FEAST", mixing_proportions = FEAST_output, Plottitle = "Test", Same_sources_flag = 0, N = 4) PlotSourceContribution(SinkNames = rownames(FEAST_output)[c(5:8)], SourceNames = colnames(FEAST_output), dir_path = "D:/科研/study/FEAST", mixing_proportions = FEAST_output, Plottitle = "Test",Same_sources_flag = 0, N = 4) Error in mixing_proportions[which(rownames(mixing_proportions) %in% SinkNames), : incorrect number of dimensions Is there anything wrong with the rownames(FEAST_output)[c(x;y)]?and what is the true code.
![image](https://user-images.githubusercontent.com/112849053/188473103-69a68818-1df2-4bab-91f4-aa6da1aa61d8.png)