I downloaded some data from gnomad - https://gnomad.broadinstitute.org/downloads. it comes in the form of VCF.bgz file and I would like to read it as a vcf file.
i wrote some code:
install.packages("R.utils")
library("R.utils")
df=gunzip("gnomad.exomes.r2.1.1.sites.4.vcf.bgz", "gnomad.exomes.r2.1.1.sites.4.vcf")
install.packages("vcfR")
library("vcfR")
vc=read.vcfR("gnomad.exomes.r2.1.1.sites.4.vcf.bgz")
but it doesn't work -- it doesn't convert it to appropriate VCF file.
Warning message:
In file.remove(filename) :
cannot remove file 'gnomad.exomes.r2.1.1.sites.4.vcf.bgz', reason 'Permission denied'
Error in read.vcfR(df) :
File: gnomad.exomes.r2.1.1.sites.4.vcf does not appear to be a VCF file.
First line of file:
gnomad.exomes.r2.1.1.sites.4.vcf
Should begin with:
##fileformat=VCFv
In addition: Warning message:
In scan(file = file, what = character(), nmax = 1, sep = "\n", quiet = TRUE, :
embedded nul(s) found in input
would appreciate any help, thank you:)
Related
I have a script that has been running smoothly for months. The last line of code basically goes as follows:
saveWorkbook(Wb, 'address/filename.xlsx'), overwrite = TRUE)
I run this script weekly (Mondays, unimportant), so I go to run it this week and I'm now getting this error when I go to save this created workbook:
Warning message:
In file.append(to[okay], from[okay]) : write error during file append
The address for this file is on a shared drive for work, so one of my first thoughts was maybe there were some new permissions for the shared drive, since saving this on local drives seems okay. But, I can save csv files on the shared drive still (using data.table::fwrite).
I'm a bit at a loss here. I've updated R, RTools, and RStudio and all my packages.
Has anyone come across this, or a similar, issue before? I could possibly be looking for some more information concerning the "write error during file append". I'm actually creating a whole new file when I run this and not appending anything to an existing file. But, I haven't been able to find anything explaining situations that could cause this error.
I have the same output but only inside a blob container on azure
overwrite instruction fails
packageVersion("openxlsx")
[1] ‘4.2.5’
> openxlsx::write.xlsx(x = mtcars,file ="mtcars.xlsx")
> openxlsx::write.xlsx(x = mtcars,file ="mtcars.xlsx")
Warning message:
In file.append(to[okay], from[okay]) : write error during file append
> openxlsx::write.xlsx(x = mtcars,file ="mtcars.xlsx",overwrite = T)
Warning message:
In file.append(to[okay], from[okay]) : write error during file append
> openxlsx::write.xlsx(x = mtcars,file ="mtcars.xlsx",overwrite = F)
Error in saveWorkbook(wb, file = file, overwrite = overwrite) :
File already exists!
Same code on my desktop produces diferent output
> packageVersion("openxlsx")
[1] ‘4.2.5’
> openxlsx::write.xlsx(x = mtcars,file ="mtcars.xlsx")
> openxlsx::write.xlsx(x = mtcars,file ="mtcars.xlsx")
> openxlsx::write.xlsx(x = mtcars,file ="mtcars.xlsx",overwrite = T)
> openxlsx::write.xlsx(x = mtcars,file ="mtcars.xlsx",overwrite = F)
Error in saveWorkbook(wb, file = file, overwrite = overwrite) :
File already exists!
As we can't fix Azure I recomend delete first and the write
> filexls= "mtcars.xlsx"
> if (file.exists(filexls)) {
+ file.remove(filexls)
+ }
[1] TRUE
> openxlsx::write.xlsx(x = mtcars,file ="mtcars.xlsx",overwrite = T)
I was following along this SO post on how to download and unzip a file.
url <- 'https://s3.amazonaws.com/dl4j-distribution/GoogleNews-vectors-negative300.bin.gz'
file <- basename(url)
download.file(url, file)
tmpdir <- tempdir()
untar(file, compressed = 'gzip', exdir = tmpdir)
Everything runs fine in the above block except the last line which returns
> untar(file, compressed = 'gzip', exdir = tmpdir)
tar: Unrecognized archive format
tar: Error exit delayed from previous errors.
Warning message:
In untar(file, compressed = "gzip", exdir = tmpdir) :
‘/usr/bin/tar -xf 'GoogleNews-vectors-negative300.bin.gz' -C '/var/folders/ll/g08vjcnd33vdhf250bbg9230fdw13f/T//RtmpAICV5a'’ returned error code 1
How can I unzip GoogleNews-vectors-negative300.bin.gz after downloading it?
I have some problems with function knit. I would like to create a report in different file everyday. So I would like to have a different name of this file each day.
And here is my problem:
When I want to do something like this:
knit("Documents/20170726_xyz.Rnw",
"Documents/20170726_xyz.tex",encoding = 'UTF-8')
Everything is ok in this case.
But when I do something like this:
if (wday(Sys.Date())==2){
date2<-Sys.Date()-3
} else {
date2<-Sys.Date()-1
}
knit(paste("Documents/",date2,"_xyz.Rnw", sep = ''",
paste("Documents/",date2,"_xyz.tex", sep = ''",encoding = 'UTF-8')
I receive an error:
Error in readLines(if (is.character(input2)) { :
cannot open the connection
In addition: Warning message:
In readLines(if (is.character(input2)) { :
cannot open file 'Dokumenty_2017-08-23_xyz.Rnw': No such file or directory
How could I do the second example properly?
I want to read a zip file from the web, my code is as followed
temp<-tempfile()
download<-download.file("http://depts.washington.edu/control/LARRY/TE/IDVs/idv1.zip",temp)
data<-read.table(unz(temp,"r.dat"),head=FALSE)
unlink(temp)
But it shows an error
Error in open.connection(file, "rt") : cannot open the connection
In addition: Warning message:
In open.connection(file, "rt") :
cannot locate file 'r.dat' in zip file 'C:\Users\CHENGF~2\AppData\Local\Temp\RtmpgtJShr\file361c5d0a55eb'
I don't know why it can't read the data, hope someone can help me!
this works for all the idv files except the idv1 which appears to be corrupted. You would need to unzip idv1.zip using another tool and read it in...
readrdat <- function(n) {
fname <- paste0("idv",n)
zipname <- paste0(fname,".zip")
weblink <- paste0("http://depts.washington.edu/control/LARRY/TE/IDVs/",zipname)
download.file(weblink,zipname)
data <- read.table(unz(zipname,paste0(fname,"/r.dat")),header=FALSE)
unlink(zipname)
return(data)
} #readrdat
lsdata <- lapply(1:15, function(n) {
tryCatch(readrdat(n), error=function(e) NULL)
})
lapply(lsdata, is.null)
This is an R script for array quality metrics. The first step is going well but after the execution of the 2nd step an error occurs.
library(arrayQualityMetrics)
library(limma)
library(tcltk)
X <-tk_choose.files(caption = "Choose X")
maData<-read.maimages(X, source="agilent", other.columns = "g", green.only=TRUE)
eSet<-new("ExpressionSet", exprs = maData$other$g, annotation =maData$genes[,7])
arrayQualityMetrics(eSet, outdir="QC_C", force = TRUE, do.logtransform = TRUE)
The program is running now but it is showing this warning message:
The directory 'QC_C' has been created.
Warning messages:
1: In svgStyleAttributes(style) :
Removing non-SVG style attribute name(s): subscripts, group.number, group.value
2: In svgStyleAttributes(style) :
Removing non-SVG style attribute name(s): subscripts, group.number, group.value
Where am I getting wrong? Is this the errors in the file or the Rscript is wrong....
Give the full path of the folder under path as below:
scanFiles<-dir(path='/path/to/folder/',pattern = ".*.txt$")