BEDOPS bedmap confusing file for option
1
0
Entering edit mode
2.4 years ago
N ▴ 10

Hi,

I've been trying to construct a for loop for getting mean methylation values across certain genomic features but for some reason bedmap is assuming my reference file is an option which makes no sense. My for loop is seen below and I just can't get it to work.

#!/bin/bash

bed={directory for data files}

map={reference map file}
 for region in $map/*.bed;
    do
       for f in *.bed; 
            do  
                 awk '{print $1 "\t" $2 "\t" $3 "\t" "-" "\t" $4}' $f | \
                 sed '1d' | \
                 bedmap --echo --mean ${region} ${bed}/${f} - > $bed/${f}_results.bed;
     done

  done 

However in my command line I keep getting the error

Error: Option "reference_filename" does not start with '--'

Can anyone guide me on why this is happening when clearly --echo and --mean are the options.

Thank You!

BEDOPS Methylation bedmap • 937 views
ADD COMMENT
2
Entering edit mode
2.4 years ago

After cleaning up the code, it looks like you are passing three files to bedmap, but it only takes two files: a reference file and a map file.

In your case, ${region} gets treated an option, which fails.

for region in "${map}"/*.bed
do
    echo "${region}"
    for f in *.bed
    do
        echo -e "\t${f}"
        awk '{print $1 "\t" $2 "\t" $3 "\t" "-" "\t" $4}' "${f}" \
            | sed '1d' \
            | bedmap --echo --mean "${region}" "${bed}/${f}" - \
            > "${bed}/${f}_results.bed";
     done
done

One of these has to go for this to work. I'm not sure what you're trying to do, so take a look at which two of the three arguments you want to keep:

"${region}" "${bed}/${f}" -

Since you're already piping in some result upstream from running awk on ${f}, my guess is that you want to keep these two:

"${region}" -

But I don't have enough information to say if that is correct.

ADD COMMENT
1
Entering edit mode

Thank you. I removed the

"$bed/${f}" 

And it worked. I forgot that the for loop was already feeding the file.

Thanks so much

ADD REPLY

Login before adding your answer.

Traffic: 2675 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6