Skip to content

Commit

Permalink
Take into account that chromosomes may be removed when specifying man…
Browse files Browse the repository at this point in the history
…ual reference (#135)
  • Loading branch information
grst authored Jun 24, 2024
1 parent 83a9f05 commit ad98e58
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
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

0 comments on commit ad98e58

Please sign in to comment.