YosefLab / Compass

In-Silico Modeling of Metabolic Heterogeneity using Single-Cell Transcriptomes
BSD 3-Clause "New" or "Revised" License
96 stars 28 forks source link

How to correctly get data from seurat object #94

Closed brycemash closed 1 year ago

brycemash commented 1 year ago

Hello, I'm trying to extract the data from a Seurat object properly to be able to run Compass.

How I got the data from seurat d <-readRDS('seurat.rds') expression_matrix <- d@assays$RNA@counts genes <- rownames(d@assays$RNA@counts) output_directory <- "broad/dunnlab/BLM/conda_libraries/compass" dir.create(output_directory, recursive = TRUE) write.csv(expression_matrix, file = paste0(output_directory, "/expression.mtx"), row.names = TRUE) write.csv(gene, file = paste0(output_directory, "/genes.tsv"), row.names = FALSE)

Compass run $ compass --data-mtx expression.mtx genes.tsv --num-processes 10 --species homo_sapiens Cache for model and media already built Evaluating Reaction Penalties... Traceback (most recent call last): File "/broad/dunnlab/BLM/conda_libraries/compass/bin/compass", line 8, in sys.exit(entry()) File "/broad/dunnlab/BLM/conda_libraries/compass/lib/python3.8/site-packages/compass/main.py", line 588, in entry penalties = eval_reaction_penalties(args['data'], args['model'], File "/broad/dunnlab/BLM/conda_libraries/compass/lib/python3.8/site-packages/compass/compass/penalties.py", line 60, in eval_reaction_penalties expression = utils.read_data(expression_file) #pd.read_csv(expression_file, sep='\t', index_col=0) File "/broad/dunnlab/BLM/conda_libraries/compass/lib/python3.8/site-packages/compass/utils.py", line 62, in read_data return read_mtx(data[0], data[1], data[2]) File "/broad/dunnlab/BLM/conda_libraries/compass/lib/python3.8/site-packages/compass/utils.py", line 114, in read_mtx mtx = scipy.io.mmread(mtx_file) File "/broad/dunnlab/BLM/conda_libraries/compass/lib/python3.8/site-packages/scipy/io/_mmio.py", line 129, in mmread return MMFile().read(source) File "/broad/dunnlab/BLM/conda_libraries/compass/lib/python3.8/site-packages/scipy/io/_mmio.py", line 578, in read self._parse_header(stream) File "/broad/dunnlab/BLM/conda_libraries/compass/lib/python3.8/site-packages/scipy/io/_mmio.py", line 642, in _parse_header self.class.info(stream) File "/broad/dunnlab/BLM/conda_libraries/compass/lib/python3.8/site-packages/scipy/io/_mmio.py", line 374, in info mmid, matrix, format, field, symmetry = \ ValueError: not enough values to unpack (expected 5, got 1)