Git Product home page Git Product logo

Comments (7)

johannesostner avatar johannesostner commented on June 1, 2024

Hi,
before answering your question, let me quickly clarify your confusion with the two repositories: SCDCdm_public is an old version of the project and not maintained anymore. This repository (scCODA) is the current one. Also, as already mentioned in your other issue (#15), you should use the dev branch atm, as we are still in development.

Regarding your issue:
It looks like something goes wrong with transforming your covariates from a subdictionary of your scanpy objects. It is intended that all the scanpy objects you want to use have the covariates saved as a subdictionary of adata.uns.
Could you show me adata.uns for one of your samples and tell me what part of it you want to use as your covariates in scCODA?

from sccoda.

bsierieb1 avatar bsierieb1 commented on June 1, 2024

thanks for the clarification, Johannes!

actually, switching to scCODA from the dev branch as suggested in #15 affected the behavior of scdcdm.util.cell_composition_data.from_scanpy_list as well. Depending on whether I pass adata or [adata] to the samples= argument, the command either gets stuck in the loop forever without any error message:

In [6]: dat.from_scanpy_list(adata,'leiden','Condition')
/opt/anaconda3/lib/python3.7/site-packages/anndata/_core/anndata.py:1056: FutureWarning: is_categorical is deprecated and will be removed in a future version.  Use is_categorical_dtype instead
  if not is_categorical(df_full[k]):

or it shows the following error message:

In [7]: dat.from_scanpy_list([adata],'leiden','Condition')
Traceback (most recent call last):

  File "<ipython-input-7-b2e2010d4dfa>", line 1, in <module>
    dat.from_scanpy_list([adata],'leiden','Condition')

  File "/Applications/python_modules/scCODA/scCODA/sccoda/util/cell_composition_data.py", line 81, in from_scanpy_list
    covariate_data = covariate_data.fillna(0)

  File "/opt/anaconda3/lib/python3.7/site-packages/pandas/core/frame.py", line 4327, in fillna
    downcast=downcast,

  File "/opt/anaconda3/lib/python3.7/site-packages/pandas/core/generic.py", line 6083, in fillna
    value=value, limit=limit, inplace=inplace, downcast=downcast

  File "/opt/anaconda3/lib/python3.7/site-packages/pandas/core/internals/managers.py", line 595, in fillna
    "fillna", value=value, limit=limit, inplace=inplace, downcast=downcast

  File "/opt/anaconda3/lib/python3.7/site-packages/pandas/core/internals/managers.py", line 409, in apply
    applied = getattr(b, f)(**kwargs)

  File "/opt/anaconda3/lib/python3.7/site-packages/pandas/core/internals/blocks.py", line 1779, in fillna
    values = values.fillna(value=value, limit=limit)

  File "/opt/anaconda3/lib/python3.7/site-packages/pandas/core/arrays/categorical.py", line 1721, in fillna
    raise ValueError("fill value must be in categories")

ValueError: fill value must be in categories

I copied adata.uns['Condition'] from adata.obs since anndata.AnnData.concatenate, which I ran earlier, stores sample labels in adata.obs.

My adata.uns is very long, but here is a representative chunk of it:

 'by_caste_cluster_99': {'logfoldchanges': array([( 1.2284319,), ( 1.304984 ,), ( 1.569442 ,), ..., (-1.1860995,),
         (-0.5953983,), (-0.8238606,)], dtype=[('99-G_d30', '   'names': array([('gene863',), ('gene2285',), ('gene864',), ..., ('gene1238',),
         ('mt:COIII',), ('mt:COI',)], dtype=[('99-G_d30', 'O')]),
  'params': {'corr_method': 'benjamini-hochberg',
   'groupby': 'leiden-caste',
   'method': 'wilcoxon',
   'reference': '99-W_d0',
   'use_raw': True},
  'pvals': array([(5.61765390e-40,), (3.44580661e-26,), (3.86548493e-26,), ...,
         (2.04712536e-17,), (1.95094975e-19,), (5.57943702e-26,)],
        dtype=[('99-G_d30', '   'pvals_adj': array([(7.95740675e-36,), (1.82515313e-22,), (1.82515313e-22,), ...,
         (4.14250438e-14,), (4.60586721e-16,), (1.97581813e-22,)],
        dtype=[('99-G_d30', '   'pvals_by_cluster_adj': array([2.00563116e-36, 6.20191172e-23, 6.91731540e-23, ...,
         1.83092240e-14, 2.11311882e-16, 9.89515423e-23]),
  'scores': array([( 13.2335415,), ( 10.586403 ,), ( 10.575635 ,), ...,
         ( -8.491087 ,), ( -9.015993 ,), (-10.54118  ,)],
        dtype=[('99-G_d30', '  'caste_colors': array(['#0000ff', '#d3d3d3'], dtype=object),
 'dendrogram_caste': {'categories_idx_ordered': array([0, 1]),
  'cor_method': 'pearson',
  'correlation_matrix': array([[ 1.        , -0.99999991],
         [-0.99999991,  1.        ]]),
  'dendrogram_info': {'color_list': array(['b'], dtype=object),
   'dcoord': array([[0.      , 2.828427, 2.828427, 0.      ]]),
   'icoord': array([[ 5.,  5., 15., 15.]]),
   'ivl': array(['G_d3', 'W_d0'], dtype=object),
   'leaves': array([0, 1])},
  'groupby': 'caste',
  'linkage': array([[0.      , 1.      , 2.828427, 2.      ]]),
  'linkage_method': 'complete'},
 'dendrogram_leiden': {'categories_idx_ordered': array([ 30,  45, 107,  15,  31,  49,  67,   4,  39,  19,  61, 116,  41,
          42,  13,  52,   3,   8,  27, 119, 154, 142,  33,  21,  74,  81,
         130, 138, 151,  59, 147,   5,  14, 125,   7, 139, 127,  79, 104,
          93, 124,  58, 135,  75,  98,  92, 106,  83, 102, 122, 112, 120,
         126,   0,  17,  91, 109, 132,  76, 100,  29,  40,  48,  55,  23,
          50,  10,  12,  47, 128,  65,  71, 101, 145,  53,  90,  78, 129,
         137,  62, 118,  94,  64, 108, 115,  72,  80,  26,  36,  87,  84,
          82,  95,  11,  20,  34,   1,  54,  16,  28,   6,  24,  38,  46,
          18,  25,  37, 134,  99, 123,  56,  97,  70,  96, 110, 121,  32,
          68,  63,  88,   2,   9,  69,  86,  22,  44,  35,  57,  85, 114,
         105, 111, 141, 153, 117, 144, 103,  43,  60, 143, 140, 152,  66,
         113, 148, 150, 133,  51, 131, 136,  73,  89,  77, 146, 149]),
  'cor_method': 'pearson',
  'correlation_matrix': array([[ 1.        , -0.14676354,  0.15651309, ..., -0.10101205,
           0.04006555,  0.00928279],
         [-0.14676354,  1.        ,  0.2997144 , ..., -0.1238984 ,
           0.03237281, -0.10339552],
         [ 0.15651309,  0.2997144 ,  1.        , ..., -0.06975539,
           0.09397619, -0.09236348],
         ...,
         [-0.10101205, -0.1238984 , -0.06975539, ...,  1.        ,
           0.44226941,  0.42576573],
         [ 0.04006555,  0.03237281,  0.09397619, ...,  0.44226941,
           1.        ,  0.02624137],
         [ 0.00928279, -0.10339552, -0.09236348, ...,  0.42576573,
           0.02624137,  1.        ]]),
  'dendrogram_info': {'color_list': array(['g', 'g', 'g', 'g', 'g', 'g', 'g', 'g', 'g', 'g', 'g', 'g', 'g',
          'g', 'g', 'g', 'g', 'g', 'r', 'r', 'r', 'r', 'r', 'r', 'r', 'r',
          'r', 'r', 'r', 'r', 'r', 'r', 'r', 'r', 'c', 'c', 'c', 'c', 'c',
          'c', 'm', 'm', 'm', 'm', 'm', 'm', 'm', 'm', 'm', 'm', 'm', 'm',
          'm', 'm', 'm', 'm', 'b', 'b', 'y', 'y', 'y', 'y', 'y', 'y', 'y',
          'y', 'y', 'y', 'y', 'k', 'k', 'k', 'k', 'k', 'k', 'k', 'k', 'k',
          'k', 'k', 'k', 'k', 'k', 'k', 'k', 'k', 'k', 'k', 'k', 'b', 'b',
          'g', 'g', 'g', 'g', 'g', 'g', 'g', 'g', 'g', 'g', 'g', 'g', 'g',
          'r', 'r', 'r', 'r', 'r', 'r', 'r', 'r', 'r', 'r', 'c', 'c', 'c',
          'c', 'c', 'c', 'c', 'c', 'c', 'b', 'b', 'm', 'm', 'm', 'm', 'm',
          'm', 'm', 'm', 'm', 'm', 'y', 'y', 'y', 'y', 'y', 'y', 'y', 'y',
          'y', 'y', 'y', 'y', 'y', 'y', 'y', 'b', 'b', 'b', 'b'],
         dtype=object),
   'dcoord': array([[0.        , 1.24550787, 1.24550787, 0.        ],
          [0.        , 1.83580538, 1.83580538, 1.24550787],
          [0.        , 1.7794803 , 1.7794803 , 0.        ],
          [0.        , 1.84859355, 1.84859355, 0.        ],
          [0.        , 1.88392743, 1.88392743, 0.        ],
          [1.84859355, 2.79847892, 2.79847892, 1.88392743],
          [1.7794803 , 3.06403458, 3.06403458, 2.79847892],
          [1.83580538, 3.62215752, 3.62215752, 3.06403458],
          [0.        , 1.73150409, 1.73150409, 0.        ],
          [0.        , 1.97536022, 1.97536022, 0.        ],
          [0.        , 2.57210022, 2.57210022, 1.97536022],
          [1.73150409, 3.38056883, 3.38056883, 2.57210022],
          [0.        , 1.72084537, 1.72084537, 0.        ],
          [0.        , 0.94718599, 0.94718599, 0.        ],
          [0.        , 1.77753704, 1.77753704, 0.94718599],
          [1.72084537, 3.49375756, 3.49375756, 1.77753704],
          [3.38056883, 4.04134385, 4.04134385, 3.49375756],
          [3.62215752, 4.91741426, 4.91741426, 4.04134385],
          [0.        , 2.57769401, 2.57769401, 0.        ],
          [0.        , 0.73153032, 0.73153032, 0.        ],
          [0.        , 1.47599023, 1.47599023, 0.73153032],
          [0.        , 2.9127713 , 2.9127713 , 1.47599023],
          [2.57769401, 4.37095543, 4.37095543, 2.9127713 ],
          [0.        , 3.00602373, 3.00602373, 0.        ],
          [0.        , 3.2117507 , 3.2117507 , 3.00602373],
          [0.        , 2.11058907, 2.11058907, 0.        ],
          [0.        , 2.31612708, 2.31612708, 2.11058907],
          [0.        , 1.83694624, 1.83694624, 0.        ],
          [0.        , 2.11826815, 2.11826815, 0.        ],
          [0.        , 2.63638911, 2.63638911, 2.11826815],
          [1.83694624, 3.01775592, 3.01775592, 2.63638911],
          [2.31612708, 3.87923732, 3.87923732, 3.01775592],
          [3.2117507 , 4.59311026, 4.59311026, 3.87923732],
          [4.37095543, 5.04290154, 5.04290154, 4.59311026],
          [0.        , 1.43643611, 1.43643611, 0.        ],
          [0.        , 2.65735037, 2.65735037, 1.43643611],
          [0.        , 1.52198719, 1.52198719, 0.        ],
          [0.        , 2.03584972, 2.03584972, 0.        ],
          [1.52198719, 3.23632378, 3.23632378, 2.03584972],
          [2.65735037, 3.56279287, 3.56279287, 3.23632378],
          [0.        , 1.58799387, 1.58799387, 0.        ],
          [0.        , 2.2656383 , 2.2656383 , 0.        ],
          [0.        , 1.5939403 , 1.5939403 , 0.        ],
          [0.        , 1.63235614, 1.63235614, 0.        ],
          [0.        , 2.70397711, 2.70397711, 1.63235614],
          [1.5939403 , 3.34682692, 3.34682692, 2.70397711],
          [2.2656383 , 3.67082594, 3.67082594, 3.34682692],
          [1.58799387, 3.82222198, 3.82222198, 3.67082594],
          [0.        , 1.45879186, 1.45879186, 0.        ],
          [0.        , 3.03313619, 3.03313619, 1.45879186],
          [0.        , 1.57159896, 1.57159896, 0.        ],
          [0.        , 1.46814825, 1.46814825, 0.        ],
          [0.        , 2.30583306, 2.30583306, 1.46814825],
          [1.57159896, 3.40655067, 3.40655067, 2.30583306],
          [3.03313619, 4.2726048 , 4.2726048 , 3.40655067],
          [3.82222198, 5.00140932, 5.00140932, 4.2726048 ],
          [3.56279287, 5.41636081, 5.41636081, 5.00140932],
          [5.04290154, 6.08676495, 6.08676495, 5.41636081],
          [0.        , 1.47923623, 1.47923623, 0.        ],
          [0.        , 2.73040872, 2.73040872, 0.        ],
          [1.47923623, 3.35046849, 3.35046849, 2.73040872],
          [0.        , 1.5051209 , 1.5051209 , 0.        ],
          [0.        , 0.8583076 , 0.8583076 , 0.        ],
          [0.        , 1.6907187 , 1.6907187 , 0.8583076 ],
          [1.5051209 , 3.82085476, 3.82085476, 1.6907187 ],
          [0.        , 1.43732178, 1.43732178, 0.        ],
          [0.        , 3.83386905, 3.83386905, 1.43732178],
          [3.82085476, 4.59101894, 4.59101894, 3.83386905],
          [3.35046849, 5.12187445, 5.12187445, 4.59101894],
          [0.        , 2.24948157, 2.24948157, 0.        ],
          [0.        , 1.73998523, 1.73998523, 0.        ],
          [0.        , 1.81856199, 1.81856199, 0.        ],
          [1.73998523, 3.14042689, 3.14042689, 1.81856199],
          [2.24948157, 4.12292813, 4.12292813, 3.14042689],
          [0.        , 1.94311898, 1.94311898, 0.        ],
          [0.        , 2.25729428, 2.25729428, 1.94311898],
          [0.        , 1.57686784, 1.57686784, 0.        ],
          [0.        , 3.17964042, 3.17964042, 1.57686784],
          [2.25729428, 3.59474271, 3.59474271, 3.17964042],
          [0.        , 2.51861149, 2.51861149, 0.        ],
          [0.        , 3.28009944, 3.28009944, 2.51861149],
          [0.        , 2.31755899, 2.31755899, 0.        ],
          [0.        , 2.61760022, 2.61760022, 2.31755899],
          [0.        , 1.7313599 , 1.7313599 , 0.        ],
          [0.        , 2.82627645, 2.82627645, 1.7313599 ],
          [2.61760022, 3.72728591, 3.72728591, 2.82627645],
          [3.28009944, 4.55736181, 4.55736181, 3.72728591],
          [3.59474271, 4.72459079, 4.72459079, 4.55736181],
          [4.12292813, 5.21053942, 5.21053942, 4.72459079],
          [5.12187445, 6.27887966, 6.27887966, 5.21053942],
          [6.08676495, 6.55538795, 6.55538795, 6.27887966],
          [0.        , 1.50123323, 1.50123323, 0.        ],
          [0.        , 1.41024434, 1.41024434, 0.        ],
          [0.        , 1.61133286, 1.61133286, 1.41024434],
          [1.50123323, 2.59361302, 2.59361302, 1.61133286],
          [0.        , 1.70193119, 1.70193119, 0.        ],
          [0.        , 1.86771288, 1.86771288, 0.        ],
          [1.70193119, 2.63576866, 2.63576866, 1.86771288],
          [2.59361302, 4.18517775, 4.18517775, 2.63576866],
          [0.        , 1.4247041 , 1.4247041 , 0.        ],
          [0.        , 0.75172721, 0.75172721, 0.        ],
          [0.        , 1.5484116 , 1.5484116 , 0.75172721],
          [1.4247041 , 4.5012878 , 4.5012878 , 1.5484116 ],
          [4.18517775, 4.97385954, 4.97385954, 4.5012878 ],
          [0.        , 2.23717961, 2.23717961, 0.        ],
          [0.        , 3.10897592, 3.10897592, 2.23717961],
          [0.        , 1.29041712, 1.29041712, 0.        ],
          [0.        , 1.36459759, 1.36459759, 0.        ],
          [1.29041712, 3.08679957, 3.08679957, 1.36459759],
          [0.        , 1.43256294, 1.43256294, 0.        ],
          [0.        , 1.49346002, 1.49346002, 0.        ],
          [1.43256294, 3.29670741, 3.29670741, 1.49346002],
          [3.08679957, 3.87760551, 3.87760551, 3.29670741],
          [3.10897592, 4.40331534, 4.40331534, 3.87760551],
          [0.        , 1.62777145, 1.62777145, 0.        ],
          [0.        , 1.68788303, 1.68788303, 0.        ],
          [1.62777145, 3.18007211, 3.18007211, 1.68788303],
          [0.        , 1.51698078, 1.51698078, 0.        ],
          [0.        , 1.59886135, 1.59886135, 0.        ],
          [0.        , 1.60407992, 1.60407992, 0.        ],
          [1.59886135, 2.46963157, 2.46963157, 1.60407992],
          [1.51698078, 3.23874393, 3.23874393, 2.46963157],
          [3.18007211, 4.66672257, 4.66672257, 3.23874393],
          [4.40331534, 5.52189337, 5.52189337, 4.66672257],
          [4.97385954, 6.03250494, 6.03250494, 5.52189337],
          [0.        , 1.23287635, 1.23287635, 0.        ],
          [0.        , 1.33482675, 1.33482675, 0.        ],
          [1.23287635, 2.24772853, 2.24772853, 1.33482675],
          [0.        , 2.04911555, 2.04911555, 0.        ],
          [0.        , 2.92766703, 2.92766703, 2.04911555],
          [0.        , 3.3174217 , 3.3174217 , 2.92766703],
          [2.24772853, 3.84813766, 3.84813766, 3.3174217 ],
          [0.        , 1.42226026, 1.42226026, 0.        ],
          [0.        , 3.84966599, 3.84966599, 1.42226026],
          [3.84813766, 4.27688955, 4.27688955, 3.84966599],
          [0.        , 2.41756226, 2.41756226, 0.        ],
          [0.        , 3.09971981, 3.09971981, 2.41756226],
          [0.        , 2.36395035, 2.36395035, 0.        ],
          [0.        , 3.11167116, 3.11167116, 2.36395035],
          [3.09971981, 3.69735092, 3.69735092, 3.11167116],
          [0.        , 1.92638517, 1.92638517, 0.        ],
          [0.        , 2.11658628, 2.11658628, 1.92638517],
          [0.        , 3.29571409, 3.29571409, 2.11658628],
          [0.        , 1.0328529 , 1.0328529 , 0.        ],
          [0.        , 2.41125077, 2.41125077, 1.0328529 ],
          [0.        , 1.71502905, 1.71502905, 0.        ],
          [0.        , 2.7339185 , 2.7339185 , 1.71502905],
          [2.41125077, 3.38578431, 3.38578431, 2.7339185 ],
          [3.29571409, 3.83294055, 3.83294055, 3.38578431],
          [3.69735092, 5.36385699, 5.36385699, 3.83294055],
          [4.27688955, 6.05468652, 6.05468652, 5.36385699],
          [6.03250494, 6.6202526 , 6.6202526 , 6.05468652],
          [6.55538795, 7.05196008, 7.05196008, 6.6202526 ],
          [4.91741426, 7.67631021, 7.67631021, 7.05196008]]),
   'icoord': array([[  15.        ,   15.        ,   25.        ,   25.        ],
          [   5.        ,    5.        ,   20.        ,   20.        ],
          [  35.        ,   35.        ,   45.        ,   45.        ],
          [  55.        ,   55.        ,   65.        ,   65.        ],
          [  75.        ,   75.        ,   85.        ,   85.        ],
          [  60.        ,   60.        ,   80.        ,   80.        ],
          [  40.        ,   40.        ,   70.        ,   70.        ],
          [  12.5       ,   12.5       ,   55.        ,   55.        ],
          [  95.        ,   95.        ,  105.        ,  105.        ],
          [ 125.        ,  125.        ,  135.        ,  135.        ],
          [ 115.        ,  115.        ,  130.        ,  130.        ],
          [ 100.        ,  100.        ,  122.5       ,  122.5       ],
          [ 145.        ,  145.        ,  155.        ,  155.        ],
          [ 175.        ,  175.        ,  185.        ,  185.        ],
          [ 165.        ,  165.        ,  180.        ,  180.        ],
          [ 150.        ,  150.        ,  172.5       ,  172.5       ],
          [ 111.25      ,  111.25      ,  161.25      ,  161.25      ],
          [  33.75      ,   33.75      ,  136.25      ,  136.25      ],
          [ 195.        ,  195.        ,  205.        ,  205.        ],
          [ 235.        ,  235.        ,  245.        ,  245.        ],
          [ 225.        ,  225.        ,  240.        ,  240.        ],
          [ 215.        ,  215.        ,  232.5       ,  232.5       ],
          [ 200.        ,  200.        ,  223.75      ,  223.75      ],
          [ 265.        ,  265.        ,  275.        ,  275.        ],
          [ 255.        ,  255.        ,  270.        ,  270.        ],
          [ 295.        ,  295.        ,  305.        ,  305.        ],
          [ 285.        ,  285.        ,  300.        ,  300.        ],
          [ 315.        ,  315.        ,  325.        ,  325.        ],
          [ 345.        ,  345.        ,  355.        ,  355.        ],
          [ 335.        ,  335.        ,  350.        ,  350.        ],
          [ 320.        ,  320.        ,  342.5       ,  342.5       ],
          [ 292.5       ,  292.5       ,  331.25      ,  331.25      ],
          [ 262.5       ,  262.5       ,  311.875     ,  311.875     ],
          [ 211.875     ,  211.875     ,  287.1875    ,  287.1875    ],
          [ 375.        ,  375.        ,  385.        ,  385.        ],
          [ 365.        ,  365.        ,  380.        ,  380.        ],
          [ 395.        ,  395.        ,  405.        ,  405.        ],
          [ 415.        ,  415.        ,  425.        ,  425.        ],
          [ 400.        ,  400.        ,  420.        ,  420.        ],
          [ 372.5       ,  372.5       ,  410.        ,  410.        ],
          [ 435.        ,  435.        ,  445.        ,  445.        ],
          [ 455.        ,  455.        ,  465.        ,  465.        ],
          [ 475.        ,  475.        ,  485.        ,  485.        ],
          [ 505.        ,  505.        ,  515.        ,  515.        ],
          [ 495.        ,  495.        ,  510.        ,  510.        ],
          [ 480.        ,  480.        ,  502.5       ,  502.5       ],
          [ 460.        ,  460.        ,  491.25      ,  491.25      ],
          [ 440.        ,  440.        ,  475.625     ,  475.625     ],
          [ 535.        ,  535.        ,  545.        ,  545.        ],
          [ 525.        ,  525.        ,  540.        ,  540.        ],
          [ 555.        ,  555.        ,  565.        ,  565.        ],
          [ 585.        ,  585.        ,  595.        ,  595.        ],
          [ 575.        ,  575.        ,  590.        ,  590.        ],
          [ 560.        ,  560.        ,  582.5       ,  582.5       ],
          [ 532.5       ,  532.5       ,  571.25      ,  571.25      ],
          [ 457.8125    ,  457.8125    ,  551.875     ,  551.875     ],
          [ 391.25      ,  391.25      ,  504.84375   ,  504.84375   ],
          [ 249.53125   ,  249.53125   ,  448.046875  ,  448.046875  ],
          [ 605.        ,  605.        ,  615.        ,  615.        ],
          [ 625.        ,  625.        ,  635.        ,  635.        ],
          [ 610.        ,  610.        ,  630.        ,  630.        ],
          [ 645.        ,  645.        ,  655.        ,  655.        ],
          [ 675.        ,  675.        ,  685.        ,  685.        ],
          [ 665.        ,  665.        ,  680.        ,  680.        ],
          [ 650.        ,  650.        ,  672.5       ,  672.5       ],
          [ 705.        ,  705.        ,  715.        ,  715.        ],
          [ 695.        ,  695.        ,  710.        ,  710.        ],
          [ 661.25      ,  661.25      ,  702.5       ,  702.5       ],
          [ 620.        ,  620.        ,  681.875     ,  681.875     ],
          [ 725.        ,  725.        ,  735.        ,  735.        ],
          [ 745.        ,  745.        ,  755.        ,  755.        ],
          [ 765.        ,  765.        ,  775.        ,  775.        ],
          [ 750.        ,  750.        ,  770.        ,  770.        ],
          [ 730.        ,  730.        ,  760.        ,  760.        ],
          [ 795.        ,  795.        ,  805.        ,  805.        ],
          [ 785.        ,  785.        ,  800.        ,  800.        ],
          [ 825.        ,  825.        ,  835.        ,  835.        ],
          [ 815.        ,  815.        ,  830.        ,  830.        ],
          [ 792.5       ,  792.5       ,  822.5       ,  822.5       ],
          [ 855.        ,  855.        ,  865.        ,  865.        ],
          [ 845.        ,  845.        ,  860.        ,  860.        ],
          [ 885.        ,  885.        ,  895.        ,  895.        ],
          [ 875.        ,  875.        ,  890.        ,  890.        ],
          [ 915.        ,  915.        ,  925.        ,  925.        ],
          [ 905.        ,  905.        ,  920.        ,  920.        ],
          [ 882.5       ,  882.5       ,  912.5       ,  912.5       ],
          [ 852.5       ,  852.5       ,  897.5       ,  897.5       ],
          [ 807.5       ,  807.5       ,  875.        ,  875.        ],
          [ 745.        ,  745.        ,  841.25      ,  841.25      ],
          [ 650.9375    ,  650.9375    ,  793.125     ,  793.125     ],
          [ 348.7890625 ,  348.7890625 ,  722.03125   ,  722.03125   ],
          [ 935.        ,  935.        ,  945.        ,  945.        ],
          [ 965.        ,  965.        ,  975.        ,  975.        ],
          [ 955.        ,  955.        ,  970.        ,  970.        ],
          [ 940.        ,  940.        ,  962.5       ,  962.5       ],
          [ 985.        ,  985.        ,  995.        ,  995.        ],
          [1005.        , 1005.        , 1015.        , 1015.        ],
          [ 990.        ,  990.        , 1010.        , 1010.        ],
          [ 951.25      ,  951.25      , 1000.        , 1000.        ],
          [1025.        , 1025.        , 1035.        , 1035.        ],
          [1055.        , 1055.        , 1065.        , 1065.        ],
          [1045.        , 1045.        , 1060.        , 1060.        ],
          [1030.        , 1030.        , 1052.5       , 1052.5       ],
          [ 975.625     ,  975.625     , 1041.25      , 1041.25      ],
          [1085.        , 1085.        , 1095.        , 1095.        ],
          [1075.        , 1075.        , 1090.        , 1090.        ],
          [1105.        , 1105.        , 1115.        , 1115.        ],
          [1125.        , 1125.        , 1135.        , 1135.        ],
          [1110.        , 1110.        , 1130.        , 1130.        ],
          [1145.        , 1145.        , 1155.        , 1155.        ],
          [1165.        , 1165.        , 1175.        , 1175.        ],
          [1150.        , 1150.        , 1170.        , 1170.        ],
          [1120.        , 1120.        , 1160.        , 1160.        ],
          [1082.5       , 1082.5       , 1140.        , 1140.        ],
          [1185.        , 1185.        , 1195.        , 1195.        ],
          [1205.        , 1205.        , 1215.        , 1215.        ],
          [1190.        , 1190.        , 1210.        , 1210.        ],
          [1225.        , 1225.        , 1235.        , 1235.        ],
          [1245.        , 1245.        , 1255.        , 1255.        ],
          [1265.        , 1265.        , 1275.        , 1275.        ],
          [1250.        , 1250.        , 1270.        , 1270.        ],
          [1230.        , 1230.        , 1260.        , 1260.        ],
          [1200.        , 1200.        , 1245.        , 1245.        ],
          [1111.25      , 1111.25      , 1222.5       , 1222.5       ],
          [1008.4375    , 1008.4375    , 1166.875     , 1166.875     ],
          [1285.        , 1285.        , 1295.        , 1295.        ],
          [1305.        , 1305.        , 1315.        , 1315.        ],
          [1290.        , 1290.        , 1310.        , 1310.        ],
          [1345.        , 1345.        , 1355.        , 1355.        ],
          [1335.        , 1335.        , 1350.        , 1350.        ],
          [1325.        , 1325.        , 1342.5       , 1342.5       ],
          [1300.        , 1300.        , 1333.75      , 1333.75      ],
          [1375.        , 1375.        , 1385.        , 1385.        ],
          [1365.        , 1365.        , 1380.        , 1380.        ],
          [1316.875     , 1316.875     , 1372.5       , 1372.5       ],
          [1405.        , 1405.        , 1415.        , 1415.        ],
          [1395.        , 1395.        , 1410.        , 1410.        ],
          [1435.        , 1435.        , 1445.        , 1445.        ],
          [1425.        , 1425.        , 1440.        , 1440.        ],
          [1402.5       , 1402.5       , 1432.5       , 1432.5       ],
          [1475.        , 1475.        , 1485.        , 1485.        ],
          [1465.        , 1465.        , 1480.        , 1480.        ],
          [1455.        , 1455.        , 1472.5       , 1472.5       ],
          [1505.        , 1505.        , 1515.        , 1515.        ],
          [1495.        , 1495.        , 1510.        , 1510.        ],
          [1535.        , 1535.        , 1545.        , 1545.        ],
          [1525.        , 1525.        , 1540.        , 1540.        ],
          [1502.5       , 1502.5       , 1532.5       , 1532.5       ],
          [1463.75      , 1463.75      , 1517.5       , 1517.5       ],
          [1417.5       , 1417.5       , 1490.625     , 1490.625     ],
          [1344.6875    , 1344.6875    , 1454.0625    , 1454.0625    ],
          [1087.65625   , 1087.65625   , 1399.375     , 1399.375     ],
          [ 535.41015625,  535.41015625, 1243.515625  , 1243.515625  ],
          [  85.        ,   85.        ,  889.46289062,  889.46289062]]),
   'ivl': array(['30', '45', '107', '15', '31', '49', '67', '4', '39', '19', '61',
          '116', '41', '42', '13', '52', '3', '8', '27', '119', '154', '142',
          '33', '21', '74', '81', '130', '138', '151', '59', '147', '5',
          '14', '125', '7', '139', '127', '79', '104', '93', '124', '58',
          '135', '75', '98', '92', '106', '83', '102', '122', '112', '120',
          '126', '0', '17', '91', '109', '132', '76', '100', '29', '40',
          '48', '55', '23', '50', '10', '12', '47', '128', '65', '71', '101',
          '145', '53', '90', '78', '129', '137', '62', '118', '94', '64',
          '108', '115', '72', '80', '26', '36', '87', '84', '82', '95', '11',
          '20', '34', '1', '54', '16', '28', '6', '24', '38', '46', '18',
          '25', '37', '134', '99', '123', '56', '97', '70', '96', '110',
          '121', '32', '68', '63', '88', '2', '9', '69', '86', '22', '44',
          '35', '57', '85', '114', '105', '111', '141', '153', '117', '144',
          '103', '43', '60', '143', '140', '152', '66', '113', '148', '150',
          '133', '51', '131', '136', '73', '89', '77', '146', '149'],
         dtype=object),
   'leaves': array([ 30,  45, 107,  15,  31,  49,  67,   4,  39,  19,  61, 116,  41,
           42,  13,  52,   3,   8,  27, 119, 154, 142,  33,  21,  74,  81,
          130, 138, 151,  59, 147,   5,  14, 125,   7, 139, 127,  79, 104,
           93, 124,  58, 135,  75,  98,  92, 106,  83, 102, 122, 112, 120,
          126,   0,  17,  91, 109, 132,  76, 100,  29,  40,  48,  55,  23,
           50,  10,  12,  47, 128,  65,  71, 101, 145,  53,  90,  78, 129,
          137,  62, 118,  94,  64, 108, 115,  72,  80,  26,  36,  87,  84,
           82,  95,  11,  20,  34,   1,  54,  16,  28,   6,  24,  38,  46,
           18,  25,  37, 134,  99, 123,  56,  97,  70,  96, 110, 121,  32,
           68,  63,  88,   2,   9,  69,  86,  22,  44,  35,  57,  85, 114,
          105, 111, 141, 153, 117, 144, 103,  43,  60, 143, 140, 152,  66,
          113, 148, 150, 133,  51, 131, 136,  73,  89,  77, 146, 149])},
  'groupby': 'leiden',
  'linkage': array([[ 21.        ,  74.        ,   0.73153032,   2.        ],
         [ 25.        ,  37.        ,   0.75172721,   2.        ],
         [ 12.        ,  47.        ,   0.8583076 ,   2.        ],
         [  8.        ,  27.        ,   0.94718599,   2.        ],
         [ 73.        ,  89.        ,   1.0328529 ,   2.        ],
         [ 85.        , 114.        ,   1.23287635,   2.        ],
         [ 45.        , 107.        ,   1.24550787,   2.        ],
         [ 56.        ,  97.        ,   1.29041712,   2.        ],
         [105.        , 111.        ,   1.33482675,   2.        ],
         [ 70.        ,  96.        ,   1.36459759,   2.        ],
         [  1.        ,  54.        ,   1.41024434,   2.        ],
         [ 43.        ,  60.        ,   1.42226026,   2.        ],
         [ 38.        ,  46.        ,   1.4247041 ,   2.        ],
         [110.        , 121.        ,   1.43256294,   2.        ],
         [ 79.        , 104.        ,   1.43643611,   2.        ],
         [ 65.        ,  71.        ,   1.43732178,   2.        ],
         [  0.        ,  17.        ,   1.45879186,   2.        ],
         [ 76.        , 100.        ,   1.46814825,   2.        ],
         [ 33.        , 155.        ,   1.47599023,   3.        ],
         [ 29.        ,  40.        ,   1.47923623,   2.        ],
         [ 32.        ,  68.        ,   1.49346002,   2.        ],
         [ 11.        ,  20.        ,   1.50123323,   2.        ],
         [ 23.        ,  50.        ,   1.5051209 ,   2.        ],
         [ 69.        ,  86.        ,   1.51698078,   2.        ],
         [ 93.        , 124.        ,   1.52198719,   2.        ],
         [ 18.        , 156.        ,   1.5484116 ,   3.        ],
         [ 91.        , 109.        ,   1.57159896,   2.        ],
         [ 64.        , 108.        ,   1.57686784,   2.        ],
         [ 75.        ,  98.        ,   1.58799387,   2.        ],
         [ 83.        , 102.        ,   1.5939403 ,   2.        ],
         [ 22.        ,  44.        ,   1.59886135,   2.        ],
         [ 35.        ,  57.        ,   1.60407992,   2.        ],
         [ 34.        , 165.        ,   1.61133286,   3.        ],
         [ 63.        ,  88.        ,   1.62777145,   2.        ],
         [112.        , 120.        ,   1.63235614,   2.        ],
         [  2.        ,   9.        ,   1.68788303,   2.        ],
         [ 10.        , 157.        ,   1.6907187 ,   3.        ],
         [ 16.        ,  28.        ,   1.70193119,   2.        ],
         [146.        , 149.        ,   1.71502905,   2.        ],
         [ 13.        ,  52.        ,   1.72084537,   2.        ],
         [ 82.        ,  95.        ,   1.7313599 ,   2.        ],
         [ 19.        ,  61.        ,   1.73150409,   2.        ],
         [ 53.        ,  90.        ,   1.73998523,   2.        ],
         [  3.        , 158.        ,   1.77753704,   3.        ],
         [ 15.        ,  31.        ,   1.7794803 ,   2.        ],
         [ 78.        , 129.        ,   1.81856199,   2.        ],
         [ 30.        , 161.        ,   1.83580538,   3.        ],
         [  5.        ,  14.        ,   1.83694624,   2.        ],
         [ 49.        ,  67.        ,   1.84859355,   2.        ],
         [  6.        ,  24.        ,   1.86771288,   2.        ],
         [  4.        ,  39.        ,   1.88392743,   2.        ],
         [ 51.        , 131.        ,   1.92638517,   2.        ],
         [ 62.        , 118.        ,   1.94311898,   2.        ],
         [ 41.        ,  42.        ,   1.97536022,   2.        ],
         [ 58.        , 135.        ,   2.03584972,   2.        ],
         [117.        , 144.        ,   2.04911555,   2.        ],
         [ 59.        , 147.        ,   2.11058907,   2.        ],
         [133.        , 206.        ,   2.11658628,   3.        ],
         [  7.        , 139.        ,   2.11826815,   2.        ],
         [ 99.        , 123.        ,   2.23717961,   2.        ],
         [160.        , 163.        ,   2.24772853,   4.        ],
         [101.        , 145.        ,   2.24948157,   2.        ],
         [137.        , 207.        ,   2.25729428,   3.        ],
         [ 92.        , 106.        ,   2.2656383 ,   2.        ],
         [132.        , 172.        ,   2.30583306,   3.        ],
         [151.        , 211.        ,   2.31612708,   3.        ],
         [ 36.        ,  87.        ,   2.31755899,   2.        ],
         [113.        , 148.        ,   2.36395035,   2.        ],
         [136.        , 159.        ,   2.41125077,   3.        ],
         [140.        , 152.        ,   2.41756226,   2.        ],
         [185.        , 186.        ,   2.46963157,   4.        ],
         [ 72.        ,  80.        ,   2.51861149,   2.        ],
         [116.        , 208.        ,   2.57210022,   3.        ],
         [119.        , 154.        ,   2.57769401,   2.        ],
         [176.        , 187.        ,   2.59361302,   5.        ],
         [ 26.        , 221.        ,   2.61760022,   3.        ],
         [192.        , 204.        ,   2.63576866,   4.        ],
         [125.        , 213.        ,   2.63638911,   3.        ],
         [127.        , 169.        ,   2.65735037,   3.        ],
         [122.        , 189.        ,   2.70397711,   3.        ],
         [ 48.        ,  55.        ,   2.73040872,   2.        ],
         [ 77.        , 193.        ,   2.7339185 ,   3.        ],
         [203.        , 205.        ,   2.79847892,   4.        ],
         [ 84.        , 195.        ,   2.82627645,   3.        ],
         [142.        , 173.        ,   2.9127713 ,   4.        ],
         [153.        , 210.        ,   2.92766703,   3.        ],
         [130.        , 138.        ,   3.00602373,   2.        ],
         [202.        , 232.        ,   3.01775592,   5.        ],
         [126.        , 171.        ,   3.03313619,   3.        ],
         [199.        , 237.        ,   3.06403458,   6.        ],
         [162.        , 164.        ,   3.08679957,   4.        ],
         [143.        , 224.        ,   3.09971981,   3.        ],
         [134.        , 214.        ,   3.10897592,   3.        ],
         [ 66.        , 222.        ,   3.11167116,   3.        ],
         [197.        , 200.        ,   3.14042689,   4.        ],
         [ 94.        , 182.        ,   3.17964042,   3.        ],
         [188.        , 190.        ,   3.18007211,   4.        ],
         [ 81.        , 241.        ,   3.2117507 ,   3.        ],
         [179.        , 209.        ,   3.23632378,   4.        ],
         [178.        , 225.        ,   3.23874393,   6.        ],
         [115.        , 226.        ,   3.28009944,   3.        ],
         [150.        , 212.        ,   3.29571409,   4.        ],
         [168.        , 175.        ,   3.29670741,   4.        ],
         [141.        , 240.        ,   3.3174217 ,   4.        ],
         [184.        , 234.        ,   3.34682692,   5.        ],
         [174.        , 235.        ,   3.35046849,   4.        ],
         [196.        , 227.        ,   3.38056883,   5.        ],
         [223.        , 236.        ,   3.38578431,   6.        ],
         [181.        , 219.        ,   3.40655067,   5.        ],
         [194.        , 198.        ,   3.49375756,   5.        ],
         [233.        , 253.        ,   3.56279287,   7.        ],
         [217.        , 250.        ,   3.59474271,   6.        ],
         [201.        , 244.        ,   3.62215752,   9.        ],
         [218.        , 259.        ,   3.67082594,   7.        ],
         [246.        , 248.        ,   3.69735092,   6.        ],
         [230.        , 238.        ,   3.72728591,   6.        ],
         [177.        , 191.        ,   3.82085476,   5.        ],
         [183.        , 268.        ,   3.82222198,   9.        ],
         [256.        , 262.        ,   3.83294055,  10.        ],
         [128.        , 170.        ,   3.83386905,   3.        ],
         [215.        , 258.        ,   3.84813766,   8.        ],
         [103.        , 166.        ,   3.84966599,   3.        ],
         [245.        , 257.        ,   3.87760551,   8.        ],
         [220.        , 242.        ,   3.87923732,   8.        ],
         [261.        , 264.        ,   4.04134385,  10.        ],
         [216.        , 249.        ,   4.12292813,   6.        ],
         [229.        , 231.        ,   4.18517775,   9.        ],
         [243.        , 263.        ,   4.2726048 ,   8.        ],
         [275.        , 276.        ,   4.27688955,  11.        ],
         [228.        , 239.        ,   4.37095543,   6.        ],
         [247.        , 277.        ,   4.40331534,  11.        ],
         [167.        , 180.        ,   4.5012878 ,   5.        ],
         [255.        , 270.        ,   4.55736181,   9.        ],
         [271.        , 274.        ,   4.59101894,   8.        ],
         [252.        , 278.        ,   4.59311026,  11.        ],
         [251.        , 254.        ,   4.66672257,  10.        ],
         [266.        , 287.        ,   4.72459079,  15.        ],
         [267.        , 279.        ,   4.91741426,  19.        ],
         [281.        , 286.        ,   4.97385954,  14.        ],
         [272.        , 282.        ,   5.00140932,  17.        ],
         [284.        , 289.        ,   5.04290154,  17.        ],
         [260.        , 288.        ,   5.12187445,  12.        ],
         [280.        , 291.        ,   5.21053942,  21.        ],
         [269.        , 273.        ,   5.36385699,  16.        ],
         [265.        , 294.        ,   5.41636081,  24.        ],
         [285.        , 290.        ,   5.52189337,  21.        ],
         [293.        , 300.        ,   6.03250494,  35.        ],
         [283.        , 298.        ,   6.05468652,  27.        ],
         [295.        , 299.        ,   6.08676495,  41.        ],
         [296.        , 297.        ,   6.27887966,  33.        ],
         [303.        , 304.        ,   6.55538795,  74.        ],
         [301.        , 302.        ,   6.6202526 ,  62.        ],
         [305.        , 306.        ,   7.05196008, 136.        ],
         [292.        , 307.        ,   7.67631021, 155.        ]]),
  'linkage_method': 'complete',
  'use_rep': 'X_scvi'},
 'leiden': {'params': {'n_iterations': -1,
   'random_state': 0,
   'resolution': 8}},
 'leiden_colors': array(['#000000', '#000000', '#ffffff', '#ffffff', '#ffffff', '#000000',
        '#000000', '#000000', '#ffffff', '#ffffff', '#000000', '#000000',
        '#000000', '#ffffff', '#000000', '#ffffff', '#000000', '#000000',
        '#000000', '#ffffff', '#000000', '#000000', '#ffffff', '#000000',
        '#000000', '#000000', '#000000', '#ffffff', '#000000', '#ffffff',
        '#ffffff', '#ffffff', '#000000', '#000000', '#000000', '#ffffff',
        '#000000', '#000000', '#000000', '#ffffff', '#ffffff', '#ffffff',
        '#ffffff', '#000000', '#ffffff', '#ffffff', '#000000', '#000000',
        '#ffffff', '#ffffff', '#000000', '#000000', '#ffffff', '#000000',
        '#000000', '#ffffff', '#000000', '#ffffff', '#000000', '#000000',
        '#000000', '#ffffff', '#000000', '#ffffff', '#000000', '#ffffff',
        '#000000', '#ffffff', '#000000', '#ffffff', '#000000', '#ffffff',
        '#000000', '#000000', '#000000', '#000000', '#000000', '#000000',
        '#000000', '#000000', '#000000', '#000000', '#000000', '#000000',
        '#000000', '#000000', '#ffffff', '#000000', '#ffffff', '#000000',
        '#000000', '#000000', '#000000', '#000000', '#000000', '#000000',
        '#000000', '#000000', '#000000', '#000000', '#000000', '#000000',
        '#000000', '#000000', '#000000', '#000000', '#000000', '#ffffff',
        '#000000', '#000000', '#000000', '#000000', '#000000', '#000000',
        '#000000', '#000000', '#ffffff', '#000000', '#000000', '#000000',
        '#000000', '#000000', '#000000', '#000000', '#000000', '#000000',
        '#000000', '#000000', '#000000', '#000000', '#000000', '#000000',
        '#000000', '#000000', '#000000', '#000000', '#000000', '#000000',
        '#000000', '#000000', '#000000', '#000000', '#000000', '#000000',
        '#000000', '#000000', '#000000', '#000000', '#000000', '#000000',
        '#000000', '#000000', '#000000', '#000000', '#000000'],
       dtype=object),
 'neighbors': {'connectivities': <85942x85942 sparse matrix of type ''
   with 1734656 stored elements in Compressed Sparse Row format>,
  'distances': <85942x85942 sparse matrix of type ''
   with 1203188 stored elements in Compressed Sparse Row format>,
  'params': {'method': 'umap',
   'metric': 'euclidean',
   'n_neighbors': 15,
   'use_rep': 'X_scvi'},
  'rp_forest': {'children': {'data': array([[     1,   1720],
           [     2,    543],
           [     3,    312],
           ...,
           [-10022,     -1],
           [-10023,     -1],
           [-10024,     -1]]),
    'start': array([     0,  19823,  39788,  59511,  79238,  99139, 118914, 138803,
           158600, 178555, 198188, 218069, 237758, 257623, 277490, 297283,
           317226, 337073, 356822, 376675])},
   'hyperplanes': {'data': array([[ 0.7123353 , -0.41642767,  0.9057436 , ..., -0.9507382 ,
            -1.3730612 ,  0.5677014 ],
           [-0.43938372,  1.6043928 ,  0.02679044, ...,  0.02176985,
            -0.3232364 , -0.04427487],
           [-0.4746039 , -0.5900814 , -2.7534137 , ..., -0.41813102,
            -2.3225498 ,  1.9612429 ],
           ...,
           [ 0.        ,  0.        ,  0.        , ...,  0.        ,
             0.        ,  0.        ],
           [ 0.        ,  0.        ,  0.        , ...,  0.        ,
             0.        ,  0.        ],
           [ 0.        ,  0.        ,  0.        , ...,  0.        ,
             0.        ,  0.        ]], dtype=float32),
    'start': array([     0,  19823,  39788,  59511,  79238,  99139, 118914, 138803,
           158600, 178555, 198188, 218069, 237758, 257623, 277490, 297283,
           317226, 337073, 356822, 376675])},
   'indices': {'data': array([[  193,  2082, 20428, ...,    -1,    -1,    -1],
           [24554, 70584, 70676, ...,    -1,    -1,    -1],
           [ 8518, 25774, 30654, ..., 76392,    -1,    -1],
           ...,
           [12027, 13522, 14934, ...,    -1,    -1,    -1],
           [ 2967,  8049, 21753, ...,    -1,    -1,    -1],
           [ 3647, 38322, 56828, ...,    -1,    -1,    -1]]),
    'start': array([     0,   9912,  19895,  29757,  39621,  49572,  59460,  69405,
            79304,  89282,  99099, 109040, 118885, 128818, 138752, 148649,
           158621, 168545, 178420, 188347])},
   'offsets': {'data': array([-5.7551036, -1.0387927, -1.1955392, ...,  0.       ,  0.       ,
            0.       ], dtype=float32),
    'start': array([     0,  19823,  39788,  59511,  79238,  99139, 118914, 138803,
           158600, 178555, 198188, 218069, 237758, 257623, 277490, 297283,
           317226, 337073, 356822, 376675])}}},
 'sample_colors': array(['#ffffff', '#ffffff', '#ffffff', '#ffffff', '#ffffff', '#ffffff',
        '#ffffff', '#ffffff', '#ffffff', '#d3d3d3', '#d3d3d3', '#d3d3d3',
        '#d3d3d3', '#0000ff', '#0000ff'], dtype=object),
 'umap': {'params': {'a': 0.5830300205483709, 'b': 1.334166992455648}},
...and adata.uns['Condition']:
 'Condition': AAAGGTAGTGGCACTC-0     W_d0
 GAAGTAATCTTACCAT-0     W_d0
 AGATAGACAGACAAGC-0     W_d0
 CCTAAGACAAGCACAG-0     W_d0
 ATCTCTACAGCTACAT-0     W_d0

 TACGGTAAGGTTGTTC-14    W_d0
 TTTACTGAGCGTCGAA-14    W_d0
 AGCGTCGCATCACCAA-14    W_d0
 ACGGAAGAGCCTGCCA-14    W_d0
 GCCGTGAAGCCGCTTG-14    W_d0
 Name: caste, Length: 85942, dtype: category
 Categories (2, object): ['G_d30', 'W_d0']}

as a workaround, I just ran a quick for loop with np.count_nonzero to create a pandas.DataFrame containing cell counts in each cluster x condition and then passed it to scdcdm.util.cell_composition_data.from_pandas.

from sccoda.

johannesostner avatar johannesostner commented on June 1, 2024

Hi @bsierieb1,
the endless loop is definitely not intended, I will add a condition to avoid this in the future!

However, I am still unsure whether you can use dat.from_scanpy_list here. Do you have an anndata object for each sample or do you have one anndata object that includes all your samples?
What dat.from_scanpy_list does is that it applies dat.from_scanpy to each element in samples. Therefore, the compositional dataset is created "row-by-row".

Additionally, I could not find where in your adata.uns the covariate information (preferably a string that is either 'G_d30' or 'W_d0') is located. So far, I assumed that one would have a subdictionary with all metadata information (i.e. covariates) in adata.uns, which can simply be used as a row of the covariate data frame, but this does not seem to be the case here.

Could you tell me if there is a way to extract your condition from adata.uns? I'd like to make dat.from_scanpy_list more flexible regarding inclusion of covariates.

from sccoda.

bsierieb1 avatar bsierieb1 commented on June 1, 2024

hi Johannes,

I only have one anndata object, not a list. However, I was using dat.from_scanpy_list instead of dat.from_scanpy because dat.from_scanpy returns a different output according to readthedocs. Instead of returning a CompositionalData object, like all the other dat.from_ functions, dat.from_scanpy returns a np.array with cell counts per cluster and a list with covariates. In my case, the np.array with cell counts per cluster is not split by condition, so it is not useful, and instead of the covariate list it simply returns adata.uns['Condition'].

Maybe the problem is that my covariate information is not a dictionary, as what you said you expect, but a pandas series? The reason it is in this format is because I started with a bunch of anndata objects (different libraries from different conditions). At some point, I concatenated them using anndata.AnnData.concatenate, which adds sample IDs to a pandas dataframe in anndata.obs. Then I generated my covariate values from the sample IDs (knowing which library corresponds to which condition).

Sorry, I just realized I made a typo in my previous comment. I said dat.uns['Condition'], but what I meant was that this is my adata.uns['Condition']:

 'Condition': AAAGGTAGTGGCACTC-0     W_d0
 GAAGTAATCTTACCAT-0     W_d0
 AGATAGACAGACAAGC-0     W_d0
 CCTAAGACAAGCACAG-0     W_d0
 ATCTCTACAGCTACAT-0     W_d0
...
 TACGGTAAGGTTGTTC-14    W_d0
 TTTACTGAGCGTCGAA-14    W_d0
 AGCGTCGCATCACCAA-14    W_d0
 ACGGAAGAGCCTGCCA-14    W_d0
 GCCGTGAAGCCGCTTG-14    W_d0
 Name: caste, Length: 85942, dtype: category
 Categories (2, object): ['G_d30', 'W_d0']}

from sccoda.

johannesostner avatar johannesostner commented on June 1, 2024

Dear @bsierieb1,
using anndata.AnnData.concatenate and having one object for all samples is actually a scenario that I did not consider when writing these functions. dat.from_scanpy is only supposed to be used within dat.from_scanpy_list or dat.from_scanpy_dict. Therefore, I don't think that scCODA currently has an automatic data conversion method for your data.

You're right, the error was caused by the series in adata.uns, but even if this was not the case, dat.from_scanpy_list([adata]) would have given you only the cell type counts over all samples.

I'll try to come up with a solution to this, but for now I'd suggest you use your workaround

from sccoda.

bsierieb1 avatar bsierieb1 commented on June 1, 2024

great, thanks! it would be great if scCODA could handle concatenated anndata objects, too, because I suspect a lot of people may first do UMAP and clustering on a concatenated data set, and then perform various downstream analyses such as compositional analysis.

from sccoda.

johannesostner avatar johannesostner commented on June 1, 2024

Version 0.1 (#17) addresses this exact task in the re-written function from_scanpy, which allows you to specify a column in adata.obs that contains the sample assignment. Covariates can be passed as a key in adata.uns (as before) or as a separate DataFrame.
I hope this solves the issue!

from sccoda.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.