Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use args.total_droplets to instantiate dataset #391

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions cellbender/remove_background/data/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,9 @@ def __init__(self,
force_empty_umi_prior: Optional[float] = None,
fraction_empties: Optional[float] = None,
ambient_counts_in_cells_low_limit: float = consts.AMBIENT_COUNTS_IN_CELLS_LOW_LIMIT,
gene_blacklist: List[int] = []):
gene_blacklist: List[int] = [],
max_total_droplets_guessed: int = consts.MAX_TOTAL_DROPLETS_GUESSED,
):
assert input_file is not None, "Attempting to load data, but no " \
"input file was specified."
self.input_file = input_file
Expand Down Expand Up @@ -113,7 +115,8 @@ def __init__(self,
# Estimate priors.
counts = np.array(self.data['matrix']
[:, self.analyzed_gene_logic].sum(axis=1)).squeeze()
self.priors = get_priors(umi_counts=counts, low_count_threshold=low_count_threshold)
self.priors = get_priors(umi_counts=counts, low_count_threshold=low_count_threshold,
max_total_droplets=max_total_droplets_guessed)

# Overwrite heuristic priors with user inputs.
if expected_cell_count is not None:
Expand Down Expand Up @@ -523,6 +526,11 @@ def restore_eliminated_features_in_cells(
def get_dataset_obj(args: argparse.Namespace) -> SingleCellRNACountsDataset:
"""Helper function that uses the argparse namespace"""

max_total_droplets_guessed = (
int(args.total_droplets * 1.1) if args.total_droplets
else consts.MAX_TOTAL_DROPLETS_GUESSED
)

return SingleCellRNACountsDataset(
input_file=args.input_file,
expected_cell_count=args.expected_cell_count,
Expand All @@ -536,4 +544,5 @@ def get_dataset_obj(args: argparse.Namespace) -> SingleCellRNACountsDataset:
low_count_threshold=args.low_count_threshold,
ambient_counts_in_cells_low_limit=args.ambient_counts_in_cells_low_limit,
fpr=args.fpr,
max_total_droplets_guessed=max_total_droplets_guessed
)