monocle3 icon indicating copy to clipboard operation
monocle3 copied to clipboard

Keep cluster IDs when converting using as.cell_data_set

Open MjelleLab opened this issue 3 years ago • 1 comments

Hi, I wonder if it is possible to keep the cluster IDS (monocyte, T-cell etc) when converting from a Seurat object using the as.cell_data_set function?

MjelleLab avatar Jan 10 '22 19:01 MjelleLab

Hi, I am not a member of Monocle3 team.

I had the exact problem. Dug deeper in the function https://rdrr.io/github/satijalab/seurat-wrappers/man/as.cell_data_set.html

cds <- as.cell_data_set(data,assay="RNA",default.reductions = "umap",group.by = "orig.ident",graph="RNA_snn_res.0.5")

r$> [email protected] %>% head                                                                                                                        
                   orig.ident nCount_RNA nFeature_RNA  percent.mt      RNA_snn_res.0.5 seurat_clusters
AAACCCACAGAGCCCT-3          3      10794         3730 13.27589402 3               3
AAAGGATCACATAGCT-3          3       1005          717  0.09950249 4               4
AAAGGGCGTCCCTCAT-3          3      16116         4627 16.85281708 5               5
AAAGGGCGTCTTTATC-3          3      68324         8887 12.67051109 3               3
AAAGGTAAGACTTGTC-3          3       4612         1969  4.11968777 9               9
AAAGGTACATAGAAAC-3          3       3504         1476  5.76484018 4               4
$> colData(cds)                                                                                                                                   
DataFrame with 6304 rows and 9 columns
                    orig.ident nCount_RNA nFeature_RNA percent.mt        RNA_snn_res.0.5 seurat_clusters    ident Size_Factor
                      <factor>  <numeric>    <integer>  <numeric>   <character>        <factor>        <factor> <factor>   <numeric>
AAACCCACAGAGCCCT-3           3      10794         3730 13.2758940  3               3        3       10794
AAAGGATCACATAGCT-3           3       1005          717  0.0995025  4               4        4        1005
AAAGGGCGTCCCTCAT-3           3      16116         4627 16.8528171  5               5        5       16116
AAAGGGCGTCTTTATC-3           3      68324         8887 12.6705111  3               3        3       68324
AAAGGTAAGACTTGTC-3           3       4612         1969  4.1196878  9               9        9        4612
...                        ...        ...          ...        ...           ...             ...             ...      ...         ...
TTTGGAGCACCTCGTT-15         15       1328          860   21.23494 8               8        8        1328
TTTGGAGGTAAGGCTG-15         15       1238          891    8.88530 4               4        4        1238
TTTGGAGGTGACTGTT-15         15       9179         3853   14.22813 6               6        6        9179
TTTGGAGTCGTAGAGG-15         15       8467         3301   18.03472 5               5        5        8467
TTTGGTTGTTATCTGG-15         15      17629         5608    4.66844 6               6        6       17629

Hope this helps,

Best, T.

mortunco avatar Mar 25 '22 20:03 mortunco