-
Notifications
You must be signed in to change notification settings - Fork 81
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Daniel strobl hvg conservation fix (#785)
* hvg conservation metric fix * pre-commit * Allow for uppercase repo owner * Fix sklearn req * bash not sh * bugfix use index * add to api * pre-commit * list instead of index * check number of genes * pre-commit * addressing comments * pre-commit * shorten line * addressing comments * pre-commit * fix checks * remove magic numbers * pre-commit * int -> numbers.Integral * Fix typo * fix dataset size assumption and duck-type hvg_unint --------- Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: Scott Gigante <[email protected]> Co-authored-by: Scott Gigante <[email protected]> Former-commit-id: 814fedc
- Loading branch information
1 parent
c5e6f56
commit 49c83bf
Showing
7 changed files
with
71 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,27 @@ | ||
from . import api | ||
from scanpy.pp import highly_variable_genes | ||
from typing import Optional | ||
|
||
|
||
def filter_celltypes(adata, min_celltype_count: Optional[int] = None): | ||
|
||
min_celltype_count = min_celltype_count or 50 | ||
min_celltype_count = min_celltype_count or api.MIN_CELLS_PER_CELLTYPE | ||
|
||
celltype_counts = adata.obs["labels"].value_counts() | ||
keep_celltypes = celltype_counts[celltype_counts >= min_celltype_count].index | ||
keep_cells = adata.obs["labels"].isin(keep_celltypes) | ||
return adata[keep_cells].copy() | ||
|
||
|
||
def precompute_hvg(adata, n_genes: Optional[int] = None): | ||
|
||
n_genes = n_genes or api.N_HVG_UNINT | ||
hvg_unint = highly_variable_genes( | ||
adata, | ||
n_top_genes=n_genes, | ||
layer="log_normalized", | ||
flavor="cell_ranger", | ||
batch_key="batch", | ||
inplace=False, | ||
) | ||
return list(hvg_unint[hvg_unint.highly_variable].index) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters