petrelharp / local_pca

Methods for examining PCA locally along the genome.
71 stars 13 forks source link

summarize_run.Rmd cannot open file connection #39

Closed justanothervanessa closed 2 months ago

justanothervanessa commented 2 months ago

Hello,

I am attempting to use the local_pca templated scripts. I am able to run run_lostruct.R fine, but I run into an error with summarize_run.Rmd despite using the same directory structure as demonstrated in your templated example. Error:

Rscript -e 'templater::render_template("summarize_run.Rmd",output="lostruct_results/type_snp_size_1000_weights_none_jobid_590013/run_summary.html",change.rootdir=TRUE)'
## run_template:
setwd('lostruct_results/type_snp_size_1000_weights_none_jobid_590013')
knitr::opts_chunk$set( fig.path=file.path('figure','run_summary',''), 
                      cache.path=file.path('cache','run_summary','') )
knitr::opts_knit$set( root.dir="." )
knit("/Users/vanessa/github/Mytilus/local_pca/summarize_run.Rmd", output = "run_summary.md",  ) 

processing file: /Users/vanessa/github/Mytilus/local_pca/summarize_run.Rmd
  |...............                                     |  29% (data_setup)     Quitting from lines 51-124 (/Users/vanessa/github/Mytilus/local_pca/summarize_run.Rmd) 
Error in file(file, "rt") : cannot open the connection
Calls: <Anonymous> ... eval_with_user_handlers -> eval -> eval -> read.csv -> read.table -> file

I've consulted Stackoverflow and the solutions offered are to provide absolute paths to the files but I haven't had success with this. Do you have any insight or suggestions? Thank you!

petrelharp commented 2 months ago

Well, the problem is

Error in file(file, "rt") : cannot open the connection
Calls: <Anonymous> ... eval_with_user_handlers -> eval -> eval -> read.csv -> read.table -> file

so it's not able to find some CSV file - apparently, one of the CSV files that is read in with summarize_run.Rmd is not there or not in the place it expects. So, go through the calls to read.csv( ) in that file and check the files are there? From a quick look, that's mds_coords.csv and *.regions.csv (i.e., one file named like X.regions.csv for each chromosome).

Another way I'd debug similar things is to open an interactive R (with the same working directory you're running this in) and execute the commands in summarize_run.Rmd. That'll tell you for sure where the error is (and a more informative error message).

petrelharp commented 2 months ago

I'm going to close this as this doesn't look like an error with the script; feel free to respond here, however (or, re-open if there is an error).