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

Take into account that chromosomes may be removed when specifying manual reference #135

Merged
merged 1 commit into from
Jun 24, 2024
Merged
Show file tree
Hide file tree
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
4 changes: 2 additions & 2 deletions src/infercnvpy/tl/_infercnv.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,15 +97,15 @@ def infercnv(
logging.warning(f"Skipped {np.sum(var_mask)} genes because they don't have a genomic position annotated. ") # type: ignore
if exclude_chromosomes is not None:
var_mask = var_mask | adata.var["chromosome"].isin(exclude_chromosomes)

tmp_adata = adata[:, ~var_mask]
reference = _get_reference(adata, reference_key, reference_cat, reference)[:, ~var_mask]

expr = tmp_adata.X if layer is None else tmp_adata.layers[layer]

if scipy.sparse.issparse(expr):
expr = expr.tocsr()

reference = _get_reference(tmp_adata, reference_key, reference_cat, reference)

var = tmp_adata.var.loc[:, ["chromosome", "start", "end"]] # type: ignore

chr_pos, chunks = zip(
Expand Down
4 changes: 4 additions & 0 deletions tests/test_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ def test_infercnv(adata_oligodendroma, reference_key, reference_cat):
cnv.tl.infercnv(adata_oligodendroma, reference_key=reference_key, reference_cat=reference_cat)


def test_infercnv_manual_reference(adata_oligodendroma):
cnv.tl.infercnv(adata_oligodendroma, reference=np.ones(adata_oligodendroma.shape[1]))


@pytest.mark.skip(
reason="rpy2 segfaults on the CI. I don't know why and don't have the time for a painful debugging session."
)
Expand Down
Loading