This is a beta test.
Question: Reformating bedGraph files in shell script
Entering edit mode

I have 100 bedGraph files that I need to reformat before converting them into bigWig files for display in UCSC Genome Browser. Briefly:

  • These bedGraph files were obtained using genomeCoverageBed on bam files (for which the SN tag did not have "chr" in front of the chromosome number).

  • Since they have no "chr" in the bedgraph file, when I convert them into bigWig files with bedGraphToBigWig, the bigwig files cannot be displayed in the UCSC Genome Browser.

I need to do 2 things to my bedGraph files:

  • Add "chr" in front of every chromosome number
  • Replace "MT" by "M"

I have managed to run the following command directly on the command line for a single file:

awk '{print "chr" $0}' file.bedgraph | sed 's/MT/M/g' > $file.modified.bedgraph

However, since I am using an actual script for all my files, I then wrote:

for i in ls($BEDGRAPHDIR/*bedgraph):

SAMPLE=`basename $i`
echo $SAMPLE

awk -v LINE="$0" '{print "chr" $LINE}' ${OUTDIR}/temp/${SAMPLE}.bedgraph | sed 's/MT/M/g' > ${OUTDIR}/temp/${SAMPLE}.modified.bedgraph


However, my .modified.bedgraph are not made - they end up empty and I get a following error (I am working on a cluster: needLargeMem: trying to allocate 0 bytes (limit: 100000000000)

I am a loss as to why my command does not work.


ADD COMMENTlink 15 months ago m93 • 150 • updated 13 months ago Biostar 20
Entering edit mode


sed 's/^/chr/;s/^chrMT/chrM/' file.bedgraph
ADD REPLYlink 15 months ago
Pierre Lindenbaum
Entering edit mode

Was literally about to add an update with that :) Thanks!

ADD REPLYlink 15 months ago
• 150

Login before adding your answer.

Powered by the version 1.6