Skip to content

Data frame columns as matrices in colData #17

@lambdamoses

Description

@lambdamoses

I encountered a problem when reading a loom file whose col_attrs include columns that are matrices. In R, data frames can have matrices as columns, so I think those should be able to be managed, or moved to reducedDims. Here's what the col_attrs look like when I debug .importLoom_DataFrame:

Browse[1]> str(df)
List of 27
 $ 10x_cluster                   : chr [1:271679(1d)] "2_H27a" "2_H27a" "2_H27a" "2_H27a" ...
 $ CellID                        : chr [1:271679(1d)] "aaaabljk-1_dev_HE27a" "aaaadhll-1_dev_HE27a" "aaaaiade-1_dev_HE27a" "aaaaodnc-1_dev_HE27a" ...
 $ CellTypes                     : chr [1:271679(1d)] "? Face mesenchyme - anterior" "? Face mesenchyme - anterior" "? Face mesenchyme - anterior" "? Face mesenchyme - anterior" ...
 $ Clusters                      : int [1:271679(1d)] 0 0 0 0 0 0 0 40 0 0 ...
 $ NonNeural_ClusterText         : chr [1:271679(1d)] "Anterior chondrogenic mesenchyme" "Anterior chondrogenic mesenchyme" "Anterior chondrogenic mesenchyme" "Anterior chondrogenic mesenchyme" ...
 $ TP_35_Recombined3Clean2_C_FBPC: num [1:35, 1:271679] 0.052657 0.023825 0.001418 0.017986 0.000611 ...
 $ UMAP                          : num [1:2, 1:271679] 8.38 3.38 8.7 3.95 8.79 ...
 $ X                             : num [1:271679(1d)] 3879 3948 3969 3921 3949 ...
 $ X_umap                        : num [1:271679(1d)] 8.38 8.7 8.79 8.4 8.28 ...
 $ Y                             : num [1:271679(1d)] 32028 32014 32049 32080 32105 ...
 $ Y_umap                        : num [1:271679(1d)] -3.38 -3.95 -3.8 -3.59 -3.5 ...

Here's the culprit where the matrices messed up:

df[] <- lapply(df, as.vector)

Here's the error I get: Error in DataFrame(df) : cannot coerce class "list" to a DataFrame

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions