Comments (6)
By the way, I took this as an excuse to acquaint myself a little more with awk
to make a workaround before this is rolled out:
awk 'BEGIN {IGNORECASE=1; FS=","}; NR==1 {print}; $4=="true" {print}' all_contig_annotations.csv > hiconf.csv
This can then be read in via scirpy.io.read_10x_vdj("hiconf.csv", filtered=False)
for the desired outcome.
from scirpy.
Hi @ktpolanski,
can't you achieve this by using read_10x_vdj(..., filtered=False)
and then subsetting by the high_confidence
column in .obs
?
from scirpy.
I did not spot that column in .obs
before, sorry about that. However, high_confidence
is a per-contig call, the values are not guaranteed to be consistent across a cell's contig pool. Here's an example:
$ grep "TTTGTCATCAGAAATG-1" all_contig_annotations.csv | cut -f 1-4 -d ,
TTTGTCATCAGAAATG-1,false,TTTGTCATCAGAAATG-1_contig_1,false
TTTGTCATCAGAAATG-1,false,TTTGTCATCAGAAATG-1_contig_2,false
TTTGTCATCAGAAATG-1,false,TTTGTCATCAGAAATG-1_contig_3,true
Attempting to read the file with filtered=False
ends up throwing an understandable error:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/jovyan/my-conda-envs/d2c/lib/python3.8/site-packages/scirpy/io/_io.py", line 290, in read_10x_vdj
return _read_10x_vdj_csv(path, filtered, include_fields)
File "/home/jovyan/my-conda-envs/d2c/lib/python3.8/site-packages/scirpy/io/_io.py", line 239, in _read_10x_vdj_csv
ir_obj.add_chain(chain_dict)
File "/home/jovyan/my-conda-envs/d2c/lib/python3.8/site-packages/scirpy/io/_datastructures.py", line 139, in add_chain
self[tmp_field] = chain.pop(tmp_field)
File "/home/jovyan/my-conda-envs/d2c/lib/python3.8/site-packages/scirpy/io/_datastructures.py", line 113, in __setitem__
raise ValueError(
ValueError: Cell-level attributes differ between different chains. Already present: `False`. Tried to add `True`.
from scirpy.
I see, so I had wrong assumptions about the high_confidence
field when implementing that. At least the datastructure caught it.
I am working on a new datastructure for scirpy (#327 / #356). This will make it easier to read in all chains and use custom filtering strategies (e.g. keep non-productive chains etc).
from scirpy.
Sure, so hopefully this works itself nicely into that. Thanks!
from scirpy.
Hi @ktpolanski,
I implemented a solution using the new data structure which is now available from the latest development version. Would be glad if you could test it!
-
Install the dev version:
pip install git+https://github.com/scverse/scirpy.git
-
You should now be able to read in the 10x data with
filtered=False
. This will keep all cells and store all chains inadata.obsm["airr"]
.ir.io.read_10x_vdj("all_contig_annotations.csv", filtered=False)
-
Then, there is now the new
index_chains
step (explanation | function doc) that will create a reference to the chains that are actually used in the analysis (while still keeping all chains around). By default, it filters out chains that are marked as non-productive and don't have a CDR3 amino acid sequence. But it is possible to customize that using thefilter
attribute and a callback function:ir.pp.index_chains(adata, filter = lambda x: x["high_confidence"] is True)
or, if you want to keep the "productive" and "CDR3" filter
ir.pp.index_chains( adata, filter = [ "productive", "require_junction_aa", "lambda x: x["high_confidence"] is True ] )
I hope it is clear how this works. Let me know if not or if you have any suggestions!
Additionally, I was wondering if in the read_10x_vdj
, filtered=False
should become the new default. It would be a breaking change though.
from scirpy.
Related Issues (20)
- tl.define_clonotypes within_group parameter returns ValueError HOT 1
- Integrate TCRdist3 HOT 5
- Retrieving specific portions of the Immune Receptor beyond the junction (or CDR3). HOT 2
- ir_dist alignment stuck HOT 4
- IEDB database cdr3_aa stored as junction_aa HOT 10
- Unclear default value for the Hamming Distance cut-off HOT 1
- Dandelion interoperability
- Where has UMI count for AIR chains gone? HOT 1
- Large dataset tutorial HOT 1
- Make sure axes of nextwork plots don't have any ticks
- Add the Morisita-Horn index for repertoire overlap similarity scores HOT 1
- Sorting logic in `index_chains()` HOT 3
- Community tutorial page
- ir.tl.ir_query fails with error 'ValueError: max_workers must be greater than 0' HOT 1
- ir.tl.clonotype_modularity - ValueError: Length of values does not match length of index HOT 2
- "read_10x_vdj" not loading data properly HOT 2
- clone definition purely using CDR3 sequence HOT 2
- Optimize TCRdist metric HOT 1
- When running 'ir.tl.define_clonotypes' on MacOS14.4.1, I've got an Error:module 'os' has no attribute 'sched_getaffinity' HOT 2
- TypeError: join() got an unexpected keyword argument 'validate' HOT 9
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from scirpy.