Skip to content

Commit 33e5b6d

Browse files
author
Asa Thibodeau
committed
Fixed bug when filtering peaks with different genomes.
1 parent 6d87e1b commit 33e5b6d

File tree

3 files changed

+37
-14
lines changed

3 files changed

+37
-14
lines changed

PEASFeatureExtraction.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ macs2 callpeak -t ${prefix}_sorted.bam.${nfrsize}.bam -f BAMPE -n ${prefix} -g '
5656

5757
#Filter error prone regions
5858
echo "--- Filtering peaks. ---"
59-
java -jar "${jarpath}PEASTools.jar" filter "${prefix}_peaks.narrowPeak" "${filterpeaks}" "${prefix}_peaks.filtered"
59+
java -jar "${jarpath}PEASTools.jar" filter "${prefix}_peaks.narrowPeak" "${filterpeaks}" "${prefix}_peaks.filtered"${CHRFILE}
6060

6161

6262
echo "--- Calling annotations & known motifs. ---"

PEASTools/src/org/jax/peastools/filter/FilterRegions.java

Lines changed: 35 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import java.io.FileWriter;
77
import java.io.IOException;
88
import java.util.TreeMap;
9+
import java.util.TreeSet;
910

1011
import org.jax.peastools.util.Location;
1112
import org.jax.peastools.util.Util;
@@ -15,17 +16,46 @@ public class FilterRegions {
1516
public static void main(String[] args){
1617
FilterRegions fb = new FilterRegions();
1718
try {
18-
fb.filter(args[0], args[1], args[2]);
19+
TreeSet<String> chromosomes = new TreeSet<String>();
20+
if(args.length > 3) {
21+
chromosomes = fb.getChromosomes(args[3]);
22+
}
23+
else {
24+
chromosomes = fb.getDefaultChromosomes();
25+
}
26+
27+
fb.filter(args[0], args[1], chromosomes, args[2]);
1928
} catch (IOException e) {
2029
e.printStackTrace();
2130
}
2231
}
32+
33+
private TreeSet<String> getDefaultChromosomes(){
34+
TreeSet<String> rv = new TreeSet<String>();
35+
for(int i = 1; i< 23; i++) {
36+
rv.add("chr"+Integer.toString(i));
37+
}
38+
return rv;
39+
}
40+
41+
private TreeSet<String> getChromosomes(String file) throws IOException{
42+
BufferedReader br = new BufferedReader(new FileReader(file));
43+
44+
TreeSet<String> rv = new TreeSet<String>();
45+
46+
while(br.ready()) {
47+
rv.add(br.readLine());
48+
}
49+
50+
br.close();
51+
52+
return rv;
53+
}
2354

24-
public void filter(String peakfile, String filter, String out) throws IOException{
55+
public void filter(String peakfile, String filter, TreeSet<String> chromosomes, String out) throws IOException{
2556
Util u = new Util();
2657
BEDPeak[] allpeaks = readPeaks(peakfile).values().toArray(new BEDPeak[0]);
2758
Location[] blacklistpeaks = u.readLocationsWithIds(filter);
28-
2959
TreeMap<String, Location[]> allsorted = u.getChrStartSorted(allpeaks);
3060
TreeMap<String, Location[]> blsorted = u.getChrStartSorted(blacklistpeaks);
3161

@@ -34,15 +64,8 @@ public void filter(String peakfile, String filter, String out) throws IOExceptio
3464
BufferedWriter bw = new BufferedWriter(new FileWriter(out));
3565
for(int i = 0; i < chrs.length; i++){
3666
String curchr = chrs[i];
37-
int chridx = 23;
38-
try{
39-
chridx = Integer.parseInt(curchr.replace("chr", ""));
40-
}
41-
catch(NumberFormatException e){
42-
}
43-
44-
//Only chromosomes 1-22
45-
if(chridx < 1 || chridx >= 23){
67+
68+
if(!chromosomes.contains(curchr)){
4669
continue;
4770
}
4871

singularity/PEAS-singularity.def

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ From: ubuntu:18.04
4545

4646
mkdir /PEAS
4747
cd /PEAS
48-
wget https://github.com/UcarLab/PEAS/releases/download/v1.2/PEAS_v1.2.zip
48+
wget https://github.com/UcarLab/PEAS/releases/download/v1.2.1/PEAS_v1.2.1.zip
4949
unzip PEAS_v1.2.zip
5050

5151

0 commit comments

Comments
 (0)