Skip to content

FilterSet2 intersect not working? #1

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

Open
seeholza opened this issue Aug 24, 2018 · 1 comment
Open

FilterSet2 intersect not working? #1

seeholza opened this issue Aug 24, 2018 · 1 comment

Comments

@seeholza
Copy link

seeholza commented Aug 24, 2018

I am trying to filter variants by chromosome and position.

Here's my code:

fn = ps.seqExample('1KG_autosomes_phase3_shapeit2_mvncall_integrated_v5_20130502_lzma.seq.gds')
f = ps.SeqArrayFile()
f.open(fn)

f.FilterReset()

# filter for chromosome
chrs_all = f.GetData('chromosome')
chrs_sel = chrs_all == '22'
f.FilterSet2(variant=chrs_sel)
# returns:  # of selected variants: 1,103,547

pos_on_chrom = f.GetData('position')
# there are 3 variants with positions < 16050319
f.FilterSet2(variant=pos_on_chrom<16050319, intersect=True)
# returns:  # of selected variants: 1,103,547

Given that there 3 variants with position < 16050319 shouldnt the last call to FilterSet2 return 3 variants?

Update
Of course some simple boolean slicing does the job, maybe I misunderstood the intention of intersect=True?

sel = np.zeros_like(chrs_all, dtype=bool)
np.putmask(sel, chrs_sel, pos_on_chrom < 16050319)  # there are 3 variants with positions < 16050319
f.FilterSet2(variant=sel)
# returns: # of selected variants: 3
@zhengxwen
Copy link
Member

Thanks for using PySeqArray.
I will look into this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants