...
Expand |
---|
title | click here to see the bedtools merge code and output |
---|
|
Code Block |
---|
language | bash |
---|
title | solution code |
---|
| bedtools merge -s -c 4,5 -o count_distinct,sum -i yeast_pairedend_sort.mapped.q1.bed > yeast_pairedend_sort.mapped.q1.merge.bed
more yeast_pairedend_sort.mapped.q1.merge.bed
wc -l yeast_pairedend_sort.mapped.q1.merge.bed
#without strand considered
bedtools merge -c 4,5,6 -o count_distinct,sum,distinct -i yeast_pairedend_sort.mapped.q1.bed > yeast_pairedend_sort.noStrand.mapped.q1.merge.bed |
Code Block |
---|
| wc -l yeast_pairedend_sort.noStrand.mapped.q1.merge.bed
40319 yeast_pairedend_sort.noStrand.mapped.q1.merge.bed #without the -s option
wc -l yeast_pairedend_sort.mapped.q1.merge.bed
76601 yeast_pairedend_sort.mapped.q1.merge.bed #with the -s option
more yeast_pairedend_sort.mapped.q1.merge.bed
chrI 219 344 + 2 66
chrI 368 469 - 1 29
chrI 684 785 - 1 37
chrI 871 955 + 6 174
chrI 971 1079 - 7 211
chrI 1216 1322 + 6 157
chrI 1347 1437 - 6 157
chrI 2892 2993 + 14 406
chrI 3010 3111 + 1 37
chrI 3013 3107 - 14 406
more yeast_pairedend_sort.noStrand.mapped.q1.merge.bed
chrI 219 344 2 66 +
chrI 368 469 1 29 -
chrI 684 785 1 37 -
chrI 871 955 6 174 +
chrI 971 1079 7 211 -
chrI 1216 1322 6 157 +
chrI 1347 1437 6 157 -
chrI 2892 2993 14 406 +
chrI 3010 3111 15 443 +,- |
|
Note the change in column order in the first set of commands. We can use awk like this to change the column order, either piped in the original command or after the fact:
Code Block |
---|
language | bash |
---|
title | using awk for column reordering |
---|
|
#after the creation of the first file
cat yeast_pairedend_sort.mapped.q1.merge.bed | awk '{print $1 "\t" $2 "\t" $3 "\t" $5 "\t" $6 "\t" $4}' > yeast_pairedend_sort.mapped.q1.merge.bed
#piped in-line
bedtools merge -s -c 4,5 -o count_distinct,sum -i yeast_pairedend_sort.mapped.q1.bed | awk '{print $1 "\t" $2 "\t" $3 "\t" $5 "\t" $6 "\t" $4}' > yeast_pairedend_sort.mapped.q1.merge.bed |
bedtools intersect: identifying where two experiments overlap (or don't overlap)
...