Skip to content

Commit

Permalink
Fixed bug when filtering peaks with different genomes.
Browse files Browse the repository at this point in the history
  • Loading branch information
Asa Thibodeau committed Jan 20, 2021
1 parent 6d87e1b commit 33e5b6d
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 14 deletions.
2 changes: 1 addition & 1 deletion PEASFeatureExtraction.sh
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ macs2 callpeak -t ${prefix}_sorted.bam.${nfrsize}.bam -f BAMPE -n ${prefix} -g '

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


echo "--- Calling annotations & known motifs. ---"
Expand Down
47 changes: 35 additions & 12 deletions PEASTools/src/org/jax/peastools/filter/FilterRegions.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import java.io.FileWriter;
import java.io.IOException;
import java.util.TreeMap;
import java.util.TreeSet;

import org.jax.peastools.util.Location;
import org.jax.peastools.util.Util;
Expand All @@ -15,17 +16,46 @@ public class FilterRegions {
public static void main(String[] args){
FilterRegions fb = new FilterRegions();
try {
fb.filter(args[0], args[1], args[2]);
TreeSet<String> chromosomes = new TreeSet<String>();
if(args.length > 3) {
chromosomes = fb.getChromosomes(args[3]);
}
else {
chromosomes = fb.getDefaultChromosomes();
}

fb.filter(args[0], args[1], chromosomes, args[2]);
} catch (IOException e) {
e.printStackTrace();
}
}

private TreeSet<String> getDefaultChromosomes(){
TreeSet<String> rv = new TreeSet<String>();
for(int i = 1; i< 23; i++) {
rv.add("chr"+Integer.toString(i));
}
return rv;
}

private TreeSet<String> getChromosomes(String file) throws IOException{
BufferedReader br = new BufferedReader(new FileReader(file));

TreeSet<String> rv = new TreeSet<String>();

while(br.ready()) {
rv.add(br.readLine());
}

br.close();

return rv;
}

public void filter(String peakfile, String filter, String out) throws IOException{
public void filter(String peakfile, String filter, TreeSet<String> chromosomes, String out) throws IOException{
Util u = new Util();
BEDPeak[] allpeaks = readPeaks(peakfile).values().toArray(new BEDPeak[0]);
Location[] blacklistpeaks = u.readLocationsWithIds(filter);

TreeMap<String, Location[]> allsorted = u.getChrStartSorted(allpeaks);
TreeMap<String, Location[]> blsorted = u.getChrStartSorted(blacklistpeaks);

Expand All @@ -34,15 +64,8 @@ public void filter(String peakfile, String filter, String out) throws IOExceptio
BufferedWriter bw = new BufferedWriter(new FileWriter(out));
for(int i = 0; i < chrs.length; i++){
String curchr = chrs[i];
int chridx = 23;
try{
chridx = Integer.parseInt(curchr.replace("chr", ""));
}
catch(NumberFormatException e){
}

//Only chromosomes 1-22
if(chridx < 1 || chridx >= 23){

if(!chromosomes.contains(curchr)){
continue;
}

Expand Down
2 changes: 1 addition & 1 deletion singularity/PEAS-singularity.def
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ From: ubuntu:18.04

mkdir /PEAS
cd /PEAS
wget https://github.com/UcarLab/PEAS/releases/download/v1.2/PEAS_v1.2.zip
wget https://github.com/UcarLab/PEAS/releases/download/v1.2.1/PEAS_v1.2.1.zip
unzip PEAS_v1.2.zip


Expand Down

0 comments on commit 33e5b6d

Please sign in to comment.