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

Refactor group_abundance #463

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
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
22 changes: 18 additions & 4 deletions src/scirpy/tl/_chain_qc.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

import awkward as ak
import numpy as np
import pandas as pd
from scanpy import logging

from scirpy import get
Expand Down Expand Up @@ -131,13 +132,26 @@

res_chain_pairing = _chain_pairing(params, res_receptor_subtype == "ambiguous", mask_has_ir, mask_multichain)

# in mdata, cells that do not have a member in the AIRR modality should have the label "no IR"
# we achieve this by initalizing the full array with "no IR" and then overwriting all entries with
# the values calculated for the AIRR modality
res_receptor_subtype_mdata = pd.Series(
np.full(fill_value="no IR", shape=(params.data.shape[0],), dtype=f"<U{string_length}"),
index=params.data.obs_names,
)
res_receptor_type_mdata = res_receptor_subtype_mdata.copy()
res_chain_pairing_mdata = res_receptor_subtype_mdata.copy()
res_receptor_subtype_mdata[params.adata.obs_names] = res_receptor_subtype
res_receptor_type_mdata[params.adata.obs_names] = res_receptor_type
res_chain_pairing_mdata[params.adata.obs_names] = res_chain_pairing

if inplace:
col_receptor_type, col_receptor_subtype, col_chain_pairing = key_added
params.set_obs(col_receptor_type, res_receptor_type)
params.set_obs(col_receptor_subtype, res_receptor_subtype)
params.set_obs(col_chain_pairing, res_chain_pairing)
params.set_obs(col_receptor_type, res_receptor_type_mdata)
params.set_obs(col_receptor_subtype, res_receptor_subtype_mdata)
params.set_obs(col_chain_pairing, res_chain_pairing_mdata)
else:
return (res_receptor_type, res_receptor_subtype, res_chain_pairing)
return (res_receptor_type_mdata, res_receptor_subtype_mdata, res_chain_pairing_mdata)

Check warning on line 154 in src/scirpy/tl/_chain_qc.py

View check run for this annotation

Codecov / codecov/patch

src/scirpy/tl/_chain_qc.py#L154

Added line #L154 was not covered by tests


def _chain_pairing(
Expand Down
Loading