Skip to content

Commit

Permalink
update output prefix
Browse files Browse the repository at this point in the history
  • Loading branch information
jakevc committed Aug 6, 2021
1 parent cfed8e3 commit e3fb63d
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 22 deletions.
53 changes: 40 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Simple peak caller for CUT&TAG data
Download the latest release binary specific for your operating system:

```
wget -O gopeaks https://github.com/maxsonBraunLab/gopeaks/releases/download/v0.1.7/gopeaks-linux-amd64
wget -O gopeaks https://github.com/maxsonBraunLab/gopeaks/releases/download/v0.1.9/gopeaks-linux-amd64
chmod +x gopeaks
```

Expand All @@ -19,30 +19,57 @@ chmod +x gopeaks
./gopeaks -h
Usage of ./gopeaks:
-bam string
Bam file with
Bam file with
-control string
Bam file with contriol signal to be subtracted
Bam file with contriol signal to be subtracted
-cs string
Supply chromosome sizes for the alignment genome if not found in the bam header
Supply chromosome sizes for the alignment genome if not found in the bam header
-mdist int
Merge distance for nearby peaks (default 150)
Merge distance for nearby peaks (default 150)
-minwidth int
Minimum width to be considered a peak (default 150)
Minimum width to be considered a peak (default 150)
-mr int
Min reads per coverage bin to be considered (default 15)
-of string
Output file to write peaks to (default "peaks.bed")
Min reads per coverage bin to be considered (default 15)
-o string
Output prefiex to write peaks and metrics file (default "sample")
-pval float
Pvalue threshold for keeping a peak bin (default 0.05)
Pvalue threshold for keeping a peak bin (default 0.05)
-slide int
Slide size for coverage bins (default 50)
Slide size for coverage bins (default 50)
-step int
Bin size for coverage bins (default 100)
Bin size for coverage bins (default 100)
-version
Print the current gopeaks version
```


## call peaks on a bam file using an IgG control

```
./gopeaks -bam ../chr1.bam -control chr1_igg.bam -cs data/hg38.known.chrom.sizes -of chr1.bed
./gopeaks -bam ../chr1.bam -control chr1_igg.bam -cs data/hg38.known.chrom.sizes -o chr1
```

## Output

Two output files are generated each with the output prefix ${prefix}, set to "sample" by default.

- sample_peaks.bed
- sample_gopeaks.json

```
head sample_peaks.bed
chr1 9950 10550
chr1 21250 22650
chr1 96050 97050
```

```
cat sample_gopeaks.json
{
"gopeaks_version": "0.1.9",
"date": "2021-08-06 11:4:58 AM",
"elapsed": "1m23.43085221s",
"prefix": "sample",
"peak_counts": 4765
}
```
1 change: 0 additions & 1 deletion conda/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ package:

source:
- url: https://github.com/maxsonBraunLab/gopeaks/archive/refs/tags/v{{ version }}.tar.gz
sha256: 85d98aea13617a211e82465629427904e42635973fd23540a309601ce15955da

build:
number: 0
Expand Down
17 changes: 9 additions & 8 deletions gopeaks.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,24 +14,24 @@ import (
"gonum.org/v1/gonum/stat/distuv"
)

const gopeaks_version = "0.1.8"
const gopeaks_version = "0.1.9"

type Metrics struct {
Version string `json:"gopeaks_version"`
Date string `json:"date"`
Elapsed string `json:"elapsed"`
Outfile string `json:"outfile"`
Prefix string `json:"prefix"`
Peaks int `json:"peak_counts"`
}

func (m *Metrics) Log() {
func (m *Metrics) Log(op string) {
resp, err := json.MarshalIndent(m, "", "\t")
if err != nil {
fmt.Println(err)
os.Exit(1)
}

f, err := os.Create("gopeaks-metrics.json")
f, err := os.Create(op + "_gopeaks.json")
defer f.Close()
if err != nil {
fmt.Println(err)
Expand All @@ -51,7 +51,7 @@ func main() {
bam := flag.String("bam", "", "Bam file with ")
cs := flag.String("cs", "", "Supply chromosome sizes for the alignment genome if not found in the bam header")
within := flag.Int("mdist", 150, "Merge distance for nearby peaks")
outfile := flag.String("of", "peaks.bed", "Output file to write peaks to")
outprefix := flag.String("o", "sample", "Output prefiex to write peaks and metrics file")
minreads := flag.Int("mr", 15, "Min reads per coverage bin to be considered")
pval := flag.Float64("pval", 0.05, "Pvalue threshold for keeping a peak bin")
step := flag.Int("step", 100, "Bin size for coverage bins")
Expand Down Expand Up @@ -122,7 +122,8 @@ func main() {
// callpeaks
peaks := callpeaks(binCounts, float64(nreads), *within, *minwidth, *minreads, *pval)

err = peaks.ExportBed3(*outfile, false)
outfile := *outprefix + "_peaks.bed"
err = peaks.ExportBed3(outfile, false)
if err != nil {
logrus.Errorln(err)
}
Expand All @@ -132,12 +133,12 @@ func main() {
Version: gopeaks_version,
Date: time.Now().Format("2006-01-02 3:4:5 PM"),
Elapsed: time.Since(startTime).String(),
Outfile: *outfile,
Prefix: *outprefix,
Peaks: peaks.Length(),
}

// log metrics to file
metrics.Log()
metrics.Log(*outprefix)
}

func scaleTreatToControl(counts []float64, s1 []float64, s2 []float64) []float64 {
Expand Down

0 comments on commit e3fb63d

Please sign in to comment.