-
Notifications
You must be signed in to change notification settings - Fork 102
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
'None' as key in kwargs when trying to merge two tmp BedTools #48
Comments
This error is because import pybedtools
annotated = pybedtools.BedTool('file1.bed')
discovered = pybedtools.BedTool('file2.bed')
ann_slop = annotated.slop(genome='hg19', b=10)
disc_slop = discovered.slop(genome='hg19', b=10)
# gives an error, because merge only operates on a single file.
# By default it's the file the BedTool points to (here, file1.bed)
#
# mergd = ann_slop.merge(disc_slop, s=True, nms=True)
# "merge" only merges one file
ann_merged = ann_slop.merge(s=True, nms=True)
# perhaps this is what you want?
in_common = ann_slop.intersect(disc_slop, s=True) What is the output you'd like to get? You may need to use args like |
I see now that I used mergeBed in an unintended way, thanks for the good explanation and the tip about 'hg19'. The output I was after was actually to first concatenate the two files and then merge them:
The solution I ended up with was what you outlined. But since I wanted the entries unique to ann_slop and disc_slop too I added them manually with an intersectBed -v against the in_common file. What would you would suggest for the pipeline above with only pybedtools? (avoiding the cat method since it truncates at BED3) |
I just committed a change b64ceb8 that checks to see if the input filenames are 1) the same type and 2) have the same number of fields. If so, then no truncation will happen. In my use-cases, I typically would cat and then merge, so the BedTool.cat() method does a post-merge unless you tell it not to; additional kwargs are sent to the merge command after cat-ing. Also keep in mind that the latest BEDTools version requires that a file be sorted before merging, but the command in BedTool.cat takes care of that. However, you're doing a slop call before merging. So something like this should do the same as the command you showed: import pybedtools
results = pybedtools.BedTool('file1.bed')\
.cat('file2.bed', post_merge=False)\
.slop(genome='hg19', b=10)\
.sort()\
.merge() |
Wonderful! Thanks. I'm closing the issue with this. |
I try to merge two BedTools objects but internally one key in kwargs is 'None' which is not accepted.
Gives the error:
And kwargs is
The slopped files are fine themselves:
The text was updated successfully, but these errors were encountered: