mojaveazure / loomR

An R-based interface for loom files
63 stars 16 forks source link

get.attribute.df error #21

Open davetang opened 6 years ago

davetang commented 6 years ago

For loom files created with velocyto, cell names are called labelled as CellID. I think this is why I'm getting an error with get.attribute.df because it expects the label cell_names.

attrs <- names(r1_loom$col.attrs)
attrs
# [1] "CellID"   "Clusters" "_X"       "_Y"

attr_df <- r1_loom$get.attribute.df(MARGIN = 2, attribute.names = attrs)
Error in `[[.H5File`(self, paste0(attribute.layer, "/", col.names)) : An object with name col_attrs/cell_names does not exist in this group
PulverCyril commented 6 years ago

Encountered the same issue, I solved it by expliciting the name of the column name using the col.names argument (row.names if you're querying for gene-related attributes). For instance, to retrieve the cell names and clusters as a dataframe, you would write::

df = lfile$get.attribute.df(MARGIN = 2, attribute.names = c("CellID", "Clusters"), col.names = "CellID")

Hope it helps !

yasinkaymaz commented 5 years ago

I have the same issue here...

> names(lfile$row.attrs)
 [1] "Accession"              "Gene"                   "_LogCV"
 [4] "_LogMean"               "_Selected"              "_Total"
 [7] "_Valid"                 "gene_dispersion"        "gene_dispersion_scaled"
[10] "gene_means"             "var_genes"
>
> attrs <- names(lfile$row.attrs)
> attr.df <- lfile$get.attribute.df(MARGIN = 1, attribute.names = attrs)
Error in `[[.H5File`(self, paste0(attribute.layer, "/", row.names)) :
  An object with name row_attrs/gene_names does not exist in this group
Sophia409 commented 5 years ago

@davetang @bopekno @yasinkaymaz @ChristophH @andrewwbutler I met the same problem,how do you solve it? And I tried your command,but it didn't work.Can anyone give me some advice? Thanks!

> attrs <- names(lfile$col.attrs)
> tha.meatdata <- lfile$get.attribute.df(MARGIN = 2, attribute.names = attrs)
Error in `[[.H5File`(self, paste0(attribute.layer, "/", col.names)) : 
  An object with name col_attrs/cell_names does not exist in this group
> df = lfile$get.attribute.df(MARGIN = 2, attribute.names = c("CellID", "Clusters"), col.names = "CellID")
Error in `.rowNamesDF<-`(x, value = value) : 
  duplicate 'row.names' are not allowed
此外: Warning message:
non-unique values when setting 'row.names': ‘10X50_5_AAGTGACCAAGT-’, ‘10X50_5_ACCGGACTCGCT-’, ‘10X50_5_ACCTTGTCTCTA-’, ‘10X50_5_ACGTCTGGCATT-’, ‘10X50_5_ACTCTGTTACCT-’, ‘10X50_5_ACTTCTGCTCCT-’, ‘10X50_5_CAGTTGCCCTTG-’, ‘10X50_5_CGGAACCTGAGT-’, ‘10X50_5_CTCACTGCCATA-’, ‘10X50_5_CTGAGACATGGT-’, ‘10X50_5_GAAACTTAACGC-’, ‘10X50_5_GAAGACACACAC-’, ‘10X50_5_GACCCTTGGGAG-’, ‘10X50_5_GATAGACAACTG-’, ‘10X50_5_GATATGTAGAAG-’, ‘10X50_5_GCACACAGAGAT-’, ‘10X50_5_GCCATGTCCGTC-’, ‘10X50_5_TCGAACTGCTGA-’, ‘10X50_6_AACACTGAGCAG-’, ‘10X50_6_ACGAACGTGTCA-’, ‘10X50_6_ACTTTGGTTTCT-’, ‘10X50_6_AGAACTTAAGCC-’, ‘10X50_6_AGGATGTTCCGC-’, ‘10X50_6_ATACTGAGGTCT-’, ‘10X50_6_CCAGCTTCCGTC-’, ‘10X50_6_TAGAGAATCTCT-’, ‘10X50_6_TCAACTGCCATA-’, ‘10X50_6_TCAGGAGAAGGC-’, ‘10X50_6_TCCAGAGGTACT-’, ‘10X50_6_TCGAACATCACG-’, ‘10X50_6_TGGATGACCTCC-’, ‘10X50_6_TTAAGAGGGACA-’, ‘10X50_7_AACAGATCAAGC-’, [... truncated] 
mojaveazure commented 5 years ago

Thanks for pointing this out, we will work on a fix.

LooLipin commented 4 years ago

Hi there, I've just run into the same problem as Sophia's. Is there a way to make row.names unique to proceed with get.attribute.df? Best, Lipin

reliscu commented 3 years ago

Having the same issue. All of the row attributes are non unique, so I cannot access them!

menage95 commented 1 year ago

Hi,

I am also having this issue when trying to extract attributes

Error in `.rowNamesDF<-`(x, value = value) : 
  duplicate 'row.names' are not allowed

Did anyone find a solution?