Teichlab / cellphonedb

MIT License
341 stars 105 forks source link

Support mtx(Matrix Market) file format as input #162

Closed CharleneZ95 closed 3 years ago

CharleneZ95 commented 4 years ago

Dear CellPhoneDB Team, Since writing a large dataset to txt is a time-consuming task, see #138. I added a functionality to load .mtx (Matrix Market) file.

Example using .mtx as input:

cellphonedb method statistical_analysis test_meta.txt input_dir

Where input_dir is the directory containing the matrix.mtx, features.tsv, and barcodes.tsv files.

Using following code to generate input files in R:

library(Matrix)

expr_data <- as(as.matrix(expr_data), 'dgCMatrix')
features <- rownames(expr_data)
barcodes <- colnames(expr_data)

# output to file
writeLines(features, file = 'features.tsv')
writeLines(barcodes, file = 'barcodes.tsv')
writeMM(expr_data, file='matrix.mtx')

Where expr_data is the data matrix with row (genes) and column (cells) labels.

dbrookeUAB commented 3 years ago

The hero we deserve. This really needs to be implemented into the main branch. Text files are not sustainable.

maxim-h commented 3 years ago

Looks like the project is completely dead, which is a shame. Maybe someone will have the time to maintain an up-to-date fork in the future.

stela2502 commented 3 years ago

Just a simple correction: The lines like writeLines(features, file = 'features.tsv') need to look like this: writeLines(features, con= 'features.tsv')

prete commented 3 years ago

Merged and fixed in #264