Skip to content

Commit

Permalink
attempting to reduce code bloat for find_clones (zktuong#329)
Browse files Browse the repository at this point in the history
* how about this?

* ok this implements the functions. got to think about how to adjust the loops to allow for the orphan vj clonotypes

* ok got find_clones more or less working with the update. need to check generate_network to ensure that the overlap is computed properly

* ok one more fix

* Update test_tools_light.py

* Update 3_dandelion_findingclones-10x_data.ipynb

* Update _tools.py

didn't realise pandas has a max number of zeroes.

* minor wording change and bug fix

* update notebooks
  • Loading branch information
zktuong authored Dec 12, 2023
1 parent 8b2fca9 commit 6f4593d
Show file tree
Hide file tree
Showing 15 changed files with 2,113 additions and 2,097 deletions.
4 changes: 2 additions & 2 deletions dandelion/preprocessing/_preprocessing.py
Original file line number Diff line number Diff line change
Expand Up @@ -2390,8 +2390,8 @@ def quantify_mutations(
time=start,
deep=(
"Updated Dandelion object: \n"
" 'data', contig-indexed clone table\n"
" 'metadata', cell-indexed clone table\n"
" 'data', contig-indexed AIRR table\n"
" 'metadata', cell-indexed observations table\n"
),
)
else:
Expand Down
8 changes: 5 additions & 3 deletions dandelion/tools/_network.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,9 @@ def generate_network(
"""
regenerate = True
if vdj_data.graph is not None:
if use_existing_graph:
if (min_size != 2) or (downsample is not None):
pass
elif use_existing_graph:
start = logg.info(
"Generating network layout from pre-computed network"
)
Expand Down Expand Up @@ -485,8 +487,8 @@ def generate_network(
time=start,
deep=(
"Updated Dandelion object: \n"
" 'data', contig-indexed clone table\n"
" 'metadata', cell-indexed clone table\n"
" 'data', contig-indexed AIRR table\n"
" 'metadata', cell-indexed observations table\n"
" 'layout', graph layout\n"
" 'graph', network constructed from distance matrices of VDJ- and VJ- chains"
),
Expand Down
888 changes: 418 additions & 470 deletions dandelion/tools/_tools.py

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dandelion/utilities/_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -1128,7 +1128,7 @@ def write_h5ddl(
if self.metadata is not None:
metadata = self.metadata.copy()
for col in metadata.columns:
if sys.version_info < (3, 9):
if pd.__version__ < "2.1.0":
weird = (
metadata[[col]].applymap(type)
!= metadata[[col]].iloc[0].apply(type)
Expand Down
10 changes: 10 additions & 0 deletions dandelion/utilities/_utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@
FALSES = ["F", "False", "false", "FALSE", False]
HEAVYLONG = ["IGH", "TRB", "TRD"]
LIGHTSHORT = ["IGK", "IGL", "TRA", "TRG"]
VCALL = "v_call"
JCALL = "j_call"
VCALLG = "v_call_genotyped"
JCALLG = "j_call_genotyped"
STRIPALLELENUM = "[*][0-9][0-9]"

# for compatibility with python>=3.10
try:
Expand Down Expand Up @@ -1094,3 +1099,8 @@ def sum_col(vals):
return np.nan
else:
return sum(vals)


def check_same_celltype(clone_def1, clone_def2):
"""Check if the first key is the same."""
return clone_def1.split("_", 1)[0] == clone_def2.split("_", 1)[0]
1,242 changes: 614 additions & 628 deletions docs/notebooks/0_dandelion_primer.ipynb

Large diffs are not rendered by default.

117 changes: 63 additions & 54 deletions docs/notebooks/1b_dandelion_noreannotation-10x_data.ipynb

Large diffs are not rendered by default.

Loading

0 comments on commit 6f4593d

Please sign in to comment.