Skip to content

Commit

Permalink
Merge pull request #41 from KrishnaswamyLab/dev
Browse files Browse the repository at this point in the history
Fix EB tutorial memory issue
  • Loading branch information
scottgigante committed Jun 27, 2018
2 parents d524144 + 39bc484 commit 946a4ae
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions Python/tutorial/EmbryoidBody.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -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"
]
Expand Down Expand Up @@ -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]"
]
},
Expand Down

0 comments on commit 946a4ae

Please # to comment.