gravatar for joe

3 hours ago by

Hi all,

I have a system command which works fine from terminal;

samtools mpileup -r chr1:1-100 -B -Q 0 input.sort.bam | awk '{gsub("[^^]","",$5);print length($5)}' > ./output.txt

I would like to implement this from R, but can't figure out how to work around the requirement to have both single(') and double(") quotes within a string, as using an escaped quote (') or (") won't work as a system command;

sys.cmd <- paste0("samtools mpileup -r ",locus.of.interest," -B -Q 0 ",input.sort.bam,"|awk '",'{gsub("[^^]","",$5);print length($5)}',"'")
"samtools mpileup -r chr1:1-100 -B -Q 0 input.sort.bam | awk '{gsub("[^^]","",$5);print length($5)}'"
sys.output <- system(sys.cmd, intern=TRUE) # DOES NOT WORK BECAUE OF (")

Any advice? Thanks!!!


modified 2 hours ago

3 hours ago


Source link