Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

invalid unsigned integer: "4e+05" #10

Closed
yikiii opened this issue Mar 23, 2023 · 1 comment
Closed

invalid unsigned integer: "4e+05" #10

yikiii opened this issue Mar 23, 2023 · 1 comment

Comments

@yikiii
Copy link

yikiii commented Mar 23, 2023

The R script trackplot.R use BWTool to extract from bigwig files,

.get_summaries = function(bedSimple, bigWigs, op_dir = getwd(), nthreads = 1){
  #bedSimple = temp_op_bed; bigWigs = list.files(path = "./", pattern = "bw"); op_dir = getwd(); nthreads = 1
  op_dir = paste0(op_dir, "/")
  
  if(!dir.exists(paths = op_dir)){
    dir.create(path = op_dir, showWarnings = FALSE, recursive = TRUE)
  }
  
  message(paste0("Extracting signals"))
  
  summaries = parallel::mclapply(bigWigs, FUN = function(bw){
    bn = gsub(pattern = "\\.bw$|\\.bigWig$", replacement = "", x = basename(bw))
    message(paste0("    Processing ", bn, " .."))
    cmd = paste("bwtool summary -with-sum -keep-bed -header", bedSimple, bw, paste0(op_dir, bn, ".summary"))
    system(command = cmd, intern = TRUE)
    paste0(op_dir, bn, ".summary")
  }, mc.cores = nthreads)
  
  summary_list = lapply(summaries, function(x){
    x = data.table::fread(x)
    colnames(x)[1] = 'chromosome'
    x = x[,.(chromosome, start, end, size, max)]
    if(all(is.na(x[,max]))){
      message("No signal! Possible cause: chromosome name mismatch between bigWigs and queried loci.")
      x[, max := 0]
    }
    x
  })
  
  
  #Remove intermediate files
  lapply(summaries, function(x) system(command = paste0("rm ", x), intern = TRUE))
  system(command = paste0("rm ", bedSimple), intern = TRUE)
  
  names(summary_list) = gsub(pattern = "*\\.summary$", replacement = "", x = basename(path = unlist(summaries)))
  summary_list
}

but a error.

Extracting signals
    Processing SRR2970503 ..
    Processing SRR2970502 ..
    Processing SRR2970504 ..
    Processing SRR2970502 ..
    Processing SRR2970506 ..
invalid unsigned integer: "4e+05"
invalid unsigned integer: "4e+05"
invalid unsigned integer: "4e+05"
invalid unsigned integer: "4e+05"
    Processing SRR2970502 ..
invalid unsigned integer: "4e+05"
invalid unsigned integer: "4e+05"
Error in setnames(x, value) : 
  Can't assign 1 names to a 0 column data.table
Calls: track_extract ... colnames<- -> names<- -> names<-.data.table -> setnames

It always happes when have a number have five zeros at the end between start and end, how can I solve this problem.

@yikiii
Copy link
Author

yikiii commented Mar 23, 2023

solved by add options(scipen = 999) to not use scientific notation.

@yikiii yikiii closed this as completed Mar 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant