Can't save h5mu from Scirpy processed gex+bcr+tcr data if I copy airr into obs
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 265
- Forks
- 50
- Avg merge
- 9d 9h
- Merged PRs (30d)
- 4
Description
Describe the bug
Can't save h5mu from Scirpy processed gex+bcr+tcr data if I copy airr into obs (i.e. tdata.obs = tdata.obs.join(ir.get.airr(tdata, tdata.obsm['airr'].fields))).
Unlike in #427 , I am on 0.13 and still suffer from the bug.
TypeError: Can't implicitly convert non-string objects to strings
Above error raised while writing key 'VJ_1_germline_alignment' of <class 'h5py._hl.group.Group'> to /
(it does this with many other columns, including all _call, _cigar columns)
To Reproduce
mdata = mu.MuData({'gex':adata.copy(),
'tcr':tdata.copy(),
'bcr':bdata.copy()})
ir.tl.chain_qc(mdata['tcr'])
ir.pp.ir_dist(mdata['tcr'], metric="hamming", sequence='nt', n_jobs=4, cutoff=20, key_added='ir_dist_nt_hamming_global')
ir.pp.ir_dist(mdata['tcr'], metric="identity", sequence='nt', n_jobs=4)
ir.tl.define_clonotypes(tdata, key_added='clone_id',
n_jobs=4, dual_ir='all', receptor_arms='all',
within_group=['receptor_type', 'donor_id_global'])
mdata['tcr'].obs = mdata['tcr'].obs.join(ir.get.airr(mdata['tcr'], mdata['tcr'].obsm['airr'].fields))
mdata.write(fname)
What else I've tried
Changing columns to categoricals
for mod in mdata.mod.keys():
for col in mdata[mod].obs.columns:
if re.findall(r'(V(?:D)?J_\d_\w_(?:call|cigar))', col):
mdata[mod].obs[col] = mdata[mod].obs[col].astype('category')
print(mod,':',col, sep='')
mdata.update()
Expected behaviour
Save the file without problems
System
OS: Linux
Python version 3.9.16
Versions of libraries involved [Muon 0.1.5, Scirpy 0.13.0, Scanpy 1.9.3]
Additional context
Add any other context about the problem here.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the mdata.write(fname) call after joining ir.get.airr(...) into mdata['tcr'].obs, and inspect how the VJ_1_germline_alignment and _call or _cigar columns are written. Reproduce with the supplied MuData and Scirpy workflow; done means the resulting h5mu file saves without the TypeError.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- data
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100