how to assign row names and colnames to a sparse matrix
1
0
Entering edit mode
9 months ago

Hi,

I'm performing single cell rna sequencing differential expression analyses in R using the public dataset which can be found here: https://www.ncbi.nlm.nih.gov/geo/query/acc.cgi?acc=GSM4952363. It has 3 data files: barcodes, features, and matrix.

These are the commands I have done so far: library(Matrix) mat <- Matrix::readMM("GSM4952363_OS_1_matrix.mtx") features <- read.delim("GSM4952363_OS_1_features.tsv") barcodes <- read.delim("GSM4952363_OS_1_barcodes.tsv")

I am in the process of adding colnames (barcodes) and rownames (features) to the sparse matrix (mat) which contains the expression data, however it gives an error message.

rownames(mat) <- features

Error in dimnamesGets(x, value) : invalid dimnames given for “dgTMatrix” object

colnames rownames matrix scRNAseq • 1.1k views
0
Entering edit mode
9 months ago
ATpoint 65k
library(Matrix)

colnames(mat) <- barcodes[,1]
rownames(mat) <- features[,1]


Mind the header=FALSE because these files have no header, otherwise the first row is used as header and that then makes the files one entry short of the dimensions of mat. Also note that features has two columns, one with Ensembl gene ID and the other with gene names. Up to you what to choose.

0
Entering edit mode

Ok, thankyou so much for your help.

0
Entering edit mode

Do you know how I might construct my single cell experiment from this stage?

0
Entering edit mode

Type ?SingleCellExperiment and learn single-cell analysis via https://bioconductor.org/books/release/OSCA/

0
Entering edit mode

Ok thanks, could you help me understand this first step. I've started with chapter 10 before chapter 4 for preprocessing.

I'm confused as to what (samples=5:10) means and also what WTChimeraData is (ie. expression data or gene names etc) and since I have already loaded my data and merged the 3 files into 1 do I need to do this step?

0
Entering edit mode

I am not going to walk you through that book, sorry. Try and error, that is how I learned it.

0
Entering edit mode

Is this a good workflow to follow? https://rpubs.com/mathetal/DEGs