I am new in bioinformatic analysis and single-cell RNA analysis using Seurat in R. I want to analyze the samples GSM7030509, GSM7030510, GSM7030511, and GSM7030512 from GEO accession GSE224727, but data is in mtx.txt format and I don't know how to create a Seurat Oject.
# Load Data
data11 <- data.table::fread("GSM7030511.matrix.txt.gz", header = F)
data[1:5,1:5]
data11[1:5,1:5]
V1 V2 V3 V4 V5
1: GID Gene CGCGATGGAGGC_Tumor CGACGCTTATTG_Tumor CTGGGTCTCTAC_Tumor
2: CRERECOMB CRERECOMB 0 0 0
3: ENSMUSG00000000001.4 Gnai3 0 0 0
4: ENSMUSG00000000003.15 Pbsn 0 0 0
5: ENSMUSG00000000028.14 Cdc45 0 0 0
The first two columns are the Features and the colnames are the Barcodes. The numbers compound the Matrix.
# Create Matrix
matrix1 <- data11[2:48530 , 3:7278]
# Create Features Objects
Features11 <- data11[, 1:2]
The barcodes I already had a saved dataframe, so I've just loaded it
# Create Barcode Objects
bc1 <- read.table('barcodes1.txt', header = F)
Barcd1 <- as.data.frame(t(bc1))
# Create Seurat Obj
rep1 <- ReadMtx(
mtx = matrix1,
features = Features11,
cells = Barcd1
)
When I try to create the Seurat Object this occur this error:
Error in path.expand(path) : argumento 'path' inválido
You should not use header = FALSE
with fread()
when you actually have headers. It will cause the column type to be character instead of numeric.
data11 <- data.table::fread("GSM7030511.matrix.txt.gz")
matrix1 <- as.matrix(data11[,3:ncol(data11)])
Set row names (here I assume you want to use the Gene column):
rownames(matrix1) <- data11$Gene
ReadMtx()
is for reading in a file, so it expects a file path as an argument. Since you have already read in the data, create the Seurat object like this:
rep1 <- CreateSeuratObject(matrix1)