Entering edit mode
17 months ago
Andy
▴
120
Hello everyone,
I noticed that one RDS file I want to use only provide gene id not gene name.
It looks like:
str(data@assays$RNA@counts)
Formal class 'dgCMatrix' [package "Matrix"] with 6 slots
..@ i : int [1:1421002083] 23 26 39 43 53 55 66 68 86 89 ...
..@ p : int [1:714332] 0 3420 4066 7251 8853 11471 15253 15958 16971 19599 ...
..@ Dim : int [1:2] 33234 714331
..@ Dimnames:List of 2
.. ..$ : chr [1:33234] "ENSG00000243485" "ENSG00000237613" "ENSG00000186092" "ENSG00000238009" ...
.. ..$ : chr [1:714331] "r1_hbca_c01_AACCATGGTATGCTTG" "r1_hbca_c01_ACGGAGACAAGCTGTT" "r1_hbca_c01_ACTGATGGTCATCGGC" "r1_hbca_c01_AGGTCATGTGCACCAC" ...
..@ x : num [1:1421002083] 1 1 1 1 2 1 4 1 1 1 ...
..@ factors : list()
I tried to use hg19 reference file to change it, however, I failed. The code works fine but the it did not changed the result.
My code is:
>library(GenomicFeatures)
>gtf_file <- "~/humanreference/hg19/genes/genes.gtf"
>txdb <- makeTxDbFromUCSC(gtf_file, organism = "Homo sapiens")
>gene_ids_gtf <- keys(txdb, keytype = "GENEID")
>gene_names_gtf <- keys(txdb, keytype = "GENENAME")
>id_to_name_gtf <- setNames(gene_names_gtf, gene_ids_gtf)
>gene_names_gtf <- id_to_name_gtf[gene_ids]
after I run these codes above, my str(data@assays$RNA@counts)
still looks same.
I am not sure how to solve this problem. Hope you can help me out. Andy
you did not change anything in the counts yet.
you may want to change the original count matrix's rownames and then create a Seurat object with that new matrix