daily documenting the problems i solve on the command line
python -m ipykernel install --user name=kernel_name
help convert SAM file to BAM file -h returns header
samtools view -F 4 -h file.sam -o file.bam
if you don't use -h, it truncates the file and you cannot perform samtools sort
ls *.sorted.bam | parallel "bedtools intersect -v -a {} -b input.bed > {.).new.bam
{} means the list from ls {.} will replace the suffix .sorted.bam with .new.bam
subset(esc.bed, grepl("^chr[0-9]{1,2}$|^chr[XY]$", seqnames))
awk {'print $1"\t"$2"\t"$3'} data.txt
https://learnbyexample.gitbooks.io/command-line-text-processing/content/gnu_awk.html
mv "$file" "${file/annotated_peaks/annotated_peaks}"
for file in annotated_peaks*; do
tail -n +2
sed -i -n -e :a -e '1,4!{P;N;D;};N;ba' file.txt
tail -n 2 file.bed file2.bed file3.bed > out.bed awk '{print $2"\t"$3"\t"$4}'