Closed zh-zhang1984 closed 3 years ago
Hi Zhongheng, @zh-zhang1984
It depends on where the data in the file are. I know that there are some conventions to follow based on http://linnarssonlab.org/loompy/conventions/index.html
If your file does not follow that convention you will not get the rownames added to the LoomExperiment
object.
Here is an example from the vignette:
suppressPackageStartupMessages({
library(LoomExperiment)
library(rhdf5)
})
l1_file <-
system.file("extdata", "L1_DRG_20_example.loom", package = "LoomExperiment")
h5read(l1_file, name = "/row_attrs/Gene")
#> [1] "Nnat" "Rasl10a" "A3galt2" "Adamts8"
#> [5] "Prmt8" "Sdc1" "1700011I03Rik" "Tprg"
#> [9] "Otoa" "Pvrl1" "Plek2" "Kcnk12"
#> [13] "Lypd6b" "Ccdc60" "Dmrtb1" "Gm16364"
#> [17] "Pi16" "Klk8" "Ly86" "Smim18"
Created on 2021-09-02 by the reprex package (v2.0.1)
If you already have the gene names, you can use the rownames<-
setter method
For example:
l1_file <- system.file(
"extdata", "L1_DRG_20_example.loom", package = "LoomExperiment"
)
le <- import(l1_file, type="LoomExperiment")
rownames(le) <- LETTERS[1:20]
Thank you for the useful suggestion, I successfully added therownames
. However, How may I add colnames
for the dataset?
colnames(le) <- LETTERS[1:20]
Note that these steps are adding row names to the in-memory representation; I think it's better to stick with the Loom file format restriction and access row attributes, e.g., rowData(loom)
, maybe selecting particular rows with row_index <- rowData(loom)$Gene %in% my_genes
; loom[row_index,]`
I can solve this issue; thank you so much for the help.
Hi, thank you for the valuable package. When I read a .loom file, how can I add rowname (gene name) to the matrix?
The above code cannot parse the rownames as indicated in
rownames: NULL
;