CCBR / CHAMPAGNE

CHromAtin iMmuno PrecipitAtion sequencinG aNalysis pipEline
https://ccbr.github.io/CHAMPAGNE/
MIT License
0 stars 2 forks source link

R scripts are producing Fontconfig errors related to cache directory #193

Open slsevilla opened 5 months ago

slsevilla commented 5 months ago

Description of the bug

Running diffbind, ran into an error with the cache directory

 # Dump .params.yml heredoc (section will be empty if parametrization is disabled)
  cat <<"END_PARAMS_SECTION" > ./.params.yml
  cpus: 4
  artifact_dir: artifacts
  input_dir: ./
  meta:
    id: !!org.codehaus.groovy.runtime.GStringImpl {}
  csvfile: comp1.macs_broad.csv
  contrast: comp1
  tool: macs_broad
  END_PARAMS_SECTION

  # Create output directory
  mkdir artifacts

  # Set parallelism for BLAS/MKL etc. to avoid over-booking of resources
  export MKL_NUM_THREADS="4"
  export OPENBLAS_NUM_THREADS="4"
  export OMP_NUM_THREADS="4"

  # Work around  https://github.com/rstudio/rmarkdown/issues/1508
  # If the symbolic link is not replaced by a physical file
  # output- and temporary files will be written to the original directory.
  mv "diffbind_report.Rmd" "diffbind_report.Rmd.orig"
  cp -L "diffbind_report.Rmd.orig" "comp1.macs_broad.Rmd"

  # Render notebook
  Rscript - <<EOF
      params = yaml::read_yaml('.params.yml')

      # Instead of rendering with params, produce a version of the R
      # markdown with param definitions set, so the notebook itself can
      # be reused
      rmd_content <- readLines('comp1.macs_broad.Rmd')

      # Extract YAML content between the first two '---'
      start_idx <- which(rmd_content == "---")[1]
      end_idx <- which(rmd_content == "---")[2]
      rmd_yaml_content <- paste(rmd_content[(start_idx+1):(end_idx-1)], collapse = "\n")
      rmd_params <- yaml::yaml.load(rmd_yaml_content)

      # Override the params
      rmd_params[['params']] <- modifyList(rmd_params[['params']], params)

      # Recursive function to add 'value' to list elements, except for top-level
      add_value_recursively <- function(lst, is_top_level = FALSE) {
          if (!is.list(lst)) {
              return(lst)
          }

          lst <- lapply(lst, add_value_recursively)
          if (!is_top_level) {
              lst <- list(value = lst)
          }
          return(lst)
      }

      # Reformat nested lists under 'params' to have a 'value' key recursively
      rmd_params[['params']] <- add_value_recursively(rmd_params[['params']], is_top_level = TRUE)

      # Convert back to YAML string
      updated_yaml_content <- as.character(yaml::as.yaml(rmd_params))

      # Remove the old YAML content
      rmd_content <- rmd_content[-((start_idx+1):(end_idx-1))]

      # Insert the updated YAML content at the right position
      rmd_content <- append(rmd_content, values = unlist(strsplit(updated_yaml_content, split = "\n")), after = start_idx)

      writeLines(rmd_content, 'comp1.macs_broad.parameterised.Rmd')

      # Render based on the updated file
      rmarkdown::render('comp1.macs_broad.parameterised.Rmd', output_file='comp1.macs_broad.html', envir = new.env())
      writeLines(capture.output(sessionInfo()), "session_info.log")
  EOF

  cat <<-END_VERSIONS > versions.yml
  "CHIPSEQ:DIFF:DIFFBIND:DIFFBIND_RMD":
      rmarkdown: $(Rscript -e "cat(paste(packageVersion('rmarkdown'), collapse='.'))")
  END_VERSIONS

Command exit status:
  1

Command output:
  1/40                  
  2/40 [unnamed-chunk-1]
  3/40                  
  4/40 [setup]          
  5/40                  
  6/40 [samples]        
  7/40                  
  8/40 [heatmap1]       
  9/40                  
  10/40 [PCA1]           
  11/40                  
  12/40 [Venn]           
  13/40                  
  14/40 [peaksORsummits] 
  15/40                  
  16/40 [DBcount]        

Command error:

  processing file: comp1.macs_broad.parameterised.Rmd
  Fontconfig error: No writable cache directories
  Fontconfig error: No writable cache directories
  Fontconfig error: No writable cache directories
  Fontconfig error: No writable cache directories
  Fontconfig error: No writable cache directories
  Fontconfig error: No writable cache directories
  Fontconfig error: No writable cache directories
  Fontconfig error: No writable cache directories
  Fontconfig error: No writable cache directories
  Fontconfig error: No writable cache directories
  Fontconfig error: No writable cache directories
  Fontconfig error: No writable cache directories
  Fontconfig error: No writable cache directories
  Fontconfig error: No writable cache directories
  Fontconfig error: No writable cache directories
  Fontconfig error: No writable cache directories

  Quitting from lines 96-102 [DBcount] (comp1.macs_broad.parameterised.Rmd)
  Error:
  ! Error processing one or more read files. Check warnings().
  Backtrace:
   1. DiffBind::dba.count(samples)
   2. DiffBind:::pv.counts(...)
   3. DiffBind:::pv.counts(...)
  Execution halted

Command used and terminal output

This was encountered running sinclair from an interactive session, submitting to SLURM

Relevant files

No response

System information

No response

slsevilla commented 5 months ago

Also getting this error now for chipseeker_annotate.R

Warning messages:
1: In normalizePath("~") :
  path[1]="/home/sevillas2": No such file or directory
2: package 'dplyr' was built under R version 4.3.2 
>> preparing features information...         2024-03-01 14:11:45 
>> identifying nearest features...       2024-03-01 14:11:45 
>> calculating distance from peak to TSS...  2024-03-01 14:11:46 
>> assigning genomic annotation...       2024-03-01 14:11:46 
>> adding gene annotation...             2024-03-01 14:11:47 
geneID type is not supported... Please report it to developer...

>> assigning chromosome lengths          2024-03-01 14:11:47 
>> done...                   2024-03-01 14:11:47 
Saving 7 x 7 in image
Fontconfig error: No writable cache directories
Fontconfig error: No writable cache directories
Fontconfig error: No writable cache directories
Fontconfig error: No writable cache directories
Fontconfig error: No writable cache directories
Fontconfig error: No writable cache directories
Fontconfig error: No writable cache directories
Fontconfig error: No writable cache directories
Fontconfig error: No writable cache directories
Fontconfig error: No writable cache directories
Fontconfig error: No writable cache directories
Fontconfig error: No writable cache directories
Fontconfig error: No writable cache directories
Fontconfig error: No writable cache directories
Fontconfig error: No writable cache directories
Fontconfig error: No writable cache directories
ls: cannot access 'SPT5_T0.gem/*.annotated.txt': No such file or directory
ls: cannot access 'SPT5_T0.gem/*.summary.txt': No such file or directory
ls: cannot access 'SPT5_T0.gem/*.genelist.txt': No such file or directory
ls: cannot access 'SPT5_T0.gem/*.annotation.Rds': No such file or directory
ls: cannot access 'SPT5_T0.gem/*.png': No such file or directory