We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent f128816 commit 447cffbCopy full SHA for 447cffb
1 file changed
src/perturbo/models/_model.py
@@ -214,6 +214,14 @@ def setup_mudata(
214
log_cpm = np.log(library_size / 1e6)
215
mdata[modalities.rna_layer].obs[size_factor_key] = log_cpm - log_cpm.mean()
216
217
+ # add gene mean estimate (legacy, for simulator)
218
+ gene_mean_key = "_gene_mean"
219
+ rna_adata = mdata[modalities.rna_layer]
220
+ mean_counts = np.mean(rna_adata.X, axis=0)
221
+ if isinstance(mean_counts, np.matrix): # occurs when summing sparse array
222
+ mean_counts = mean_counts.A1
223
+ rna_adata.var["_gene_mean"] = mean_counts
224
+
225
# add indices to enable pyro subsampling of local vars
226
mdata[modalities.rna_layer].obs = mdata[modalities.rna_layer].obs.assign(_ind_x=lambda x: np.arange(len(x)))
227
index_field = fields.MuDataNumericalObsField(
0 commit comments