2

I have two Rscripts named iHS.hist.R and Fst.hist.R. I know both scripts work. When I use the following commands in my directory in my ubuntu terminal I get a histogram plot for each script (two total if I do both scripts)

module load R

Rscript iHS.hist.R

or I could do Rscript Fst.hist.R

The point is I know they both work.

The problem is that each Rscript takes about 20 minutes to run because my data is pretty big. And unfortunately it's only going to get bigger. I have access to a cluster and I would like to make use of that. I have created two .sh scripts to send to the cluster with qsub but I am running into issues. Here is my iHS.his.sh script for my iHS.hist.R script.

#PBS -N iHS.plots
#PBS -S /bin/bash
#PBS -l walltime=2:00:00
#PBS -l nodes=1:ppn=8
#PBS -l mem=4gb
#PBS -o $HOME/${PBS_JOBNAME}.o${PBS_JOBID}.log
#PBS -e $HOME/${PBS_JOBNAME}.e${PBS_JOBID}.err

###############related commands
###edit it
#code in qsub


###############cut columns we don't need
###
cut -f1,2,3,4 /group/stranger-lab/ebeiter/test/SNPsnap_mdd_5_100/matched_snps_annotated.txt > /group/stranger-lab/ebeiter/test/SNPsnap_mdd_5_100/cut.matched_snps_annotated.txt
cut -f1,2 /group/stranger-lab/ebeiter/test/SNPsnap_mdd_5_100/input_snps_insufficient_matches.txt > /group/stranger-lab/ebeiter/test/SNPsnap_mdd_5_100/cut.input_snps_insufficient_matches.txt
###
###############only needed columns remain

cd /group/stranger-lab/ebeiter
module load R
Rscript iHS.hist.R

The cuts in the beginning are for setting up the data in the right format. I have tried qsub iHS.hist.sh and it gives me a job. I check on it, and after about 10 minutes it finishes. So I'm assuming it's running my Rscript. I check the error file and it's empty. I check the log file and it does not give me the usual null device 1 that I get after my jpeg is completed in my Rscript. I don't get the output jpeg file for the Rscript when the cluster job is done. I do get the output jpeg file if I just did the Rscript on it's own like at the top of this. Any idea what is going on?

Evan
  • 1,477
  • 1
  • 17
  • 34
  • In the above script, if you substitute iHS.hist.R with another script that just writes "hello" to a file, does it work? – konvas Aug 04 '15 at 14:55
  • I made a Rscript that just prints a value and yes it worked if I replaced the `Rscript iHS.plot.sh` with `Rscript hello.R` at the bottom of my .sh – Evan Aug 04 '15 at 15:15
  • How are you saving to jpeg inside iHS.hist.R ? Do you use `jpeg(...)`? – konvas Aug 04 '15 at 16:01
  • This would be specific to your cluster, but could it be that the plot is saved in some temporary working dir and after executing your R script you need to copy it back to $HOME ? – konvas Aug 04 '15 at 16:09
  • @konvas, I am making it by `jpeg("/path/to/my/directory/filename.jpg")`, and then ending it by `dev.off()`. I have checked the ~ directory and my directory for the file. And when I run the `hello.R` it saves to my directory when I do `write.table(data, file="/path/to/my/dir/filename/")` Thoughts? – Evan Aug 04 '15 at 16:16
  • I don't really know.. have you tried other graphics devices, e.g. pdf? – konvas Aug 04 '15 at 16:33
  • I solved it!!! Somehow the `cd /group/stranger-lab/ebeiter` was messing it up somehow. I removed that and now it works! Any ideas why though? – Evan Aug 04 '15 at 16:45
  • Glad it works.. I have no idea why changing dir would only affect writing to jpeg and not to a text file. – konvas Aug 04 '15 at 16:48

0 Answers0