diff --git a/Python/tutorial/EmbryoidBody.ipynb b/Python/tutorial/EmbryoidBody.ipynb index f1aa94a..e7c6329 100644 --- a/Python/tutorial/EmbryoidBody.ipynb +++ b/Python/tutorial/EmbryoidBody.ipynb @@ -281,9 +281,12 @@ "source": [ "mito_genes = [gene_symbol.startswith('MT-') for gene_symbol in EBT_counts.columns] # Get all mitochondrial genes. There are 14, FYI.\n", "\n", - "lib_size = EBT_counts.sum(axis=1)\n", + "lib_size = EBT_counts.to_coo().tocsr().sum(axis=1)\n", "\n", - "mito_expression = np.mean(EBT_counts.loc[:,mito_genes].values / lib_size.values[:,None], axis=1)\n", + "mito_expression = (EBT_counts.loc[:,mito_genes].to_coo().tocsr().multiply(1 / lib_size)).mean(axis=1)\n", + "\n", + "mito_expression = np.array(mito_expression).flatten() # mean returns a matrix, we want an array\n", + "lib_size = np.array(lib_size).flatten()\n", "\n", "top_pct = np.percentile(mito_expression, 90) # top 10 percentile" ] @@ -386,7 +389,7 @@ "metadata": {}, "outputs": [], "source": [ - "genes_keep = np.sum(EBT_counts > 0, axis=0) > 10\n", + "genes_keep = (EBT_counts > 0).sum(axis=0) > 10\n", "EBT_counts = EBT_counts.loc[:,genes_keep]" ] },