Error while reading mlc file from CODEML in ggtree / treeio - r

I'm trying to read an mlc file (output from CODEML program) using the read.codeml_mlc function from the treeio package, as follows:
library(ggtree)
library(treeio)
tree <- read.codeml_mlc(mlc_file)
However, I'm getting the following error:
Error in strsplit(., split = "[[:space:]]") :
non character argument
Does anyone have an idea of what could be wrong? This is an ordinary mlc output from PAML from a free ratio branch model, I have not modified or altered it. However, the error seems to be related to my file, because I have tried running the example from the tutorial (reading the mlc file provided with the package) and it works fine.
Put it some other way: Where does the strsplit function come about when reading the mlc file and what part exactly of the file is it refering to? Maybe knowing that will help solve my problem.
Thanks in advance for any help that could be provided!!

Related

Base does not exist R

I have been trying to perform methylation data analysis, however I am stuck on the first few steps. I am trying to follow the workflow mentioned here and I am unable to read in my files as it gives me an error saying base does not exist.
library(methylationArrayAnalysis)
library(knitr)
library(limma)
library(minfi)
library(IlluminaHumanMethylation450kanno.ilmn12.hg19)
library(IlluminaHumanMethylation450kmanifest)
library(RColorBrewer)
library(missMethyl)
library(minfiData)
library(Gviz)
library(DMRcate)
library(stringr)
library(IlluminaHumanMethylationEPICanno.ilm10b4.hg19)
library(conumee)
dataDirectory <- "C:/Users/35389/Desktop/Medullos/All_combined/"
list.files(dataDirectory, recursive = TRUE)
target_EPIC <- read.metharray.sheet("C:/Users/35389/Desktop/Medullos/All_combined/", pattern = "sample_sheet_2.csv") #tried first with dataDirectory then put the link to files again by myself and still the same error of base does not exist
Error in read.metharray.sheet("C:/Users/35389/Desktop/Medullos/All_combined/", : 'base' does not exists
I have been trying to get around this error for a while now.
I tried to read in the methylation files directly using read.methyarray.exp() however, that way, it greatly reduces the dimensions of my data
I wonder if anyone of you has had any experiences with this and any help would be greatly appreciated! :)

Gzip error when reading R data files into julia

I'm getting an error from gzip when reading an R data file. I'm trying to use the approach described here: Reading and writing RData files in Julia.
Here's a minimal example. In R, I run the following script:
var1 <- matrix( runif(9), 3, 3 )
save( var1, file='~/temp/file1.rda')
Then in julia:
using DataFrames
x = read_rda("~/temp/file1.rda")
This returns:
ERROR: GZip.GZError(-1,"gzopen failed")
in gzopen at /home/squipbar/.julia/v0.4/GZip/src/GZip.jl:250
in gzopen at /home/squipbar/.julia/v0.4/GZip/src/GZip.jl:265
in read_rda at /home/squipbar/.julia/v0.4/DataFrames/src/RDA.jl:418
I don't think that I'm doing anything dumb. The closest I've found to this error online is in the RDatasets github issues, here: https://github.com/johnmyleswhite/RDatasets.jl/issues/32
So perhaps this is somehow related to RDatasets? Suggestions very welcome.
As you found, tilde expansion is not automatic. You can use expanduser() to expand to the full file name.
julia> expanduser("~/Desktop")
"/Users/mycomputer/Desktop"
Ok, I figured this one out. It's the expansion of "~" in the location. The following works:
using DataFrames
x = read_rda("/home/squipbar/temp/file1.rda")
So I guess I learnt two things here: 1) The error message for read_rda is not that helpful, a File not found message would have saved me a lot of time, and 2) that you can't use ~ in this case (is this a general thing in Julia?)

R: Error thrown while using RGDAL and RASTER packages

To whom this may concern:
Here is the source code:
GRA_D1<- raster(files[[1]])
//Sets up an empty output raster:
GRA_D1<- writeStart(GRA_D1,filename='GRA_D1.tif', format='GTiff', overwrite=TRUE)
//Write to the raster, for loop:
for(i in 1:dim(GRA_D1)[1]){
//Extract raster values at rows
d.Frame<- matrix(NA,ncol=2,nrow=dim(GRA_D1)[2])
d.Frame[,1]<- getValues(r1[[1]],i)
d.Frame[,2]<- getValues(r1[[2]],i)
w.Frame<- as.data.frame(d.Frame)
names(w.Frame)<- c("D1_pred_disAg","D1_pred_RK")
//Apply the predictive model:
m.pred<-predict(mod.1, w.Frame)
//Write the predictions to the empty TIFF raster
GRA_D1<-writeValues(GRA_D1,m.pred,i)
print(i)}
//Finish writing to the raster
GRA_D1<- writeStop(GRA_D1)
I am attempting to write output to an empty TIFF raster, but I keep receiving the following error message:
#Error in .local(.Object, ...) :
`general_file_path\GRA_D1.tif' does not exist in the file system,
and is not recognised as a supported dataset name.
I wonder if this is related to misusing functions in either the RGDAL or RASTER package.
Could someone please assist me?
Thanks in advance for your generosity.
Cheers,
AD
Super simple fix. Cannot believe that it is this simple and that it took me this long, but here is the answer:
"rgdal" and/or "GTiff" files don't like the use of underscores in their dataset names.
When running the code with "GRAD1.tif" (instead of "GRA_D1.tif"), all works well.
You really should not be doing any of this, I think, as you could do:
p <- predict(r1, mod.1, filename='GRA_D1.tif')
(and that filename works just fine)

How to save Variant Call Format (VCF) file to disk in R using VariantAnnotation Package

I've searched the web for this without much luck. More or less you always get to the example from the VariantAnnotation Package. And since this example works fine on my computer I have no idea why the VCF I created does not.
The problem: I want to determine the number and location of SNPs in selected genes. I have a large VCF file (over 5GB) that has info on all SNPs on all chromosomes for several mice strains. Obviously my computer freezes if I try to do anything on the whole genome scale, so I first determined genomic locations of genes of interest on chromosome 1. I then used the VariantAnnotation Package to get only the data relating to my genes of interest out of the VCF file:
library(VariantAnnotation)
param<-ScanVcfParam(
info=c("AC1","AF1","DP","DP4","INDEL","MDV","MQ","MSD","PV0","PV1","PV2","PV3","PV4","QD"),
geno=c("DP","GL","GQ","GT","PL","SP","FI"),
samples=strain,
fixed="FILTER",
which=gnrng
)
The code above is taken out of a function I wrote which takes strain as an argument. gnrng refers to a GRanges object containing genomic locations of my genes of interest.
vcf<-readVcf(file, "mm10",param)
This works fine and I get my vcf (dim: 21783 1) but when I try to save it won't work
file.vcf<-tempfile()
writeVcf(vcf, file.vcf)
Error in .pasteCollapse(ALT, ",") : 'x' must be a CharacterList
I even tried in parallel, doing the example from the package first and then substituting for my VCF file:
#This is the example:
out1.vcf<-tempfile()
in1<-readVcf(fl,"hg19")
writeVcf(in1,out1.vcf)
This works just fine, but if I only substitute in1 for my vcf I get the same error.
I hope I made myself clear... And any help will be greatly appreciated!! Thanks in advance!
Thanks for reporting this bug. The problem is fixed in version 1.9.47 (devel branch). The fix will be available in the release branch after April 14.
The problem was that you selectively imported 'FILTER' from the 'fixed' field but not 'ALT'. writeVcf() was throwing an error because there was no ALT value to write out. If you don't have access to the version with the fix, a work around would be to import the ALT field.
ScanVcfParam(fixed = c("ALT", "FILTER"))
You can see what values were imorted with the fixed() accessor:
fixed(vcf)
Please report and bugs or problems on the Bioconductor mailing list Martin referenced. More Bioc users will see the question and you'll get help more quickly.
Valerie
Here's a reproducible example
library(VariantAnnotation)
fl <- system.file("extdata", "chr22.vcf.gz", package="VariantAnnotation")
param <- ScanVcfParam(fixed="FILTER")
writeVcf(readVcf(fl, "hg19", param=param), tempfile())
## Error in .pasteCollapse(ALT, ",") : 'x' must be a CharacterList
The problem seems to be that writeVcf expects the object to have an 'ALT' field, so
param <- ScanVcfParam(fixed="ALT")
writeVcf(readVcf(fl, "hg19", param=param), tempfile())
succeeds.

R Language: Error in read.table(file.path(data.dir, file_name1)) : no lines available in input

I am having a hard time coding in R language. What I am trying to do is read large amount of data in to one data frame, and make pretty pictures.
This is what I have:
# assign data
file_name1<-"data1_txt"
file_name2<-"data2_txt"
data.dir<-"/...../Documents/R programing Language/"
for(i in 1:length(1)){
newData1<-read.table(file.path(data.dir, file_name1))
#Replace negative numbers with NA
xx <- which(datavalues<0)
datavalues[xx] <- NA
newData2<-read.table(file.path(data.dir,file_name2))
}
Error I have is:
Error in read.table(file.path(data.dir, file_name1)) :
no lines available in input
I am trying to figure out by myself, but I am very new to R language, and I don't have enough knowledge of functions in R. Please explain what this error means and advice on my coding.
Thank you very much,
Uka
Similar situation was solved here with similar question (I know this post is quite old). Recently I got such error parsing several files... The reason was some files were empty which makes sense of error message.
Anyway, just make sure your input will not be empty using try ou trycatch as suggested on mentioned link.

Resources