Base does not exist R - 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! :)

Related

How to run the acoustic index analysis of M (Median of the amplitude envelope) for multiple files in a folder in rStudio?

I am trying to run a acoustic analysis of M for multiple files in a folder. I tried various ways with loops, but really unexperienced with writing them so struggling. However, that doesn't seem to be the problem, because the error message I'll get the error message:
"Error in inputw(wave = wave, f = f, channel) : argument "f" is missing, with no default".
When I then define f (which according to the help information is the sampling frequency of wave (in Hz). Does not need to be specified if embedded in wave.), so adding "f=48000", I receive the error message: "Error in fft(wave) : non-numeric argument"
When I run a single file out of the many, I do not have to define f at all. So I am a bit confused.
I understand that it is always more helpful adding your actual script in here, but if anyone can even help me with writing a loop for this that would be much appreciated. As mentioned before, I am very inexperience when it comes to that.
Looking forward to your answers and learn more.
Here is the code I wrote:
library(seewave) #for the package M
setwd("/Users/fiene123/Desktop/samples Sounds/August27-28_outside_Unit14_1am")
ldf <- list() # creates a list
listcsv <- dir(pattern = "*.wav") # creates the list of all the csv files in the directory
for (k in 1:length(listcsv)){
ldf[[k]] <- M(listcsv[k], plot = FALSE)
}

Create CYT object in CytoTree in R

I want to create a CytoTree CYT object in R to analyse my .FCS files. When I am using the Quick start code in the package description, I will always get an error when running the createCYT() function that says:
Error in createCYT(raw.data = fcs.data, normalization.method = "log") :
2022-09-26 15:46:26 meta.data must be a data.frame
As the function should not rely on any meta data and that object is optional, I do not know how to solve the error.
Here is the description:
https://ytdai.github.io/CytoTree/quick-start.html#quick-start-code
I thank you very much in advance for your help!
BR
I have encountered same problem previously.
In the end it worked only when the data.frame was added (yes, even though it should not depend on it).
Here is how:
meta.data <- data.frame(cell = rownames(fcs.data), stage = gsub(".fcs.+", "", rownames(fcs.data)))
meta.data$stage <- factor(as.character(meta.data$stage))
You may as well have a look at the Cytotree PDF in case of more issues.

Error while reading mlc file from CODEML in ggtree / treeio

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!!

Error in eval(expr, envir, enclos) : object 'score' not found

We have always been an SPSS shop but we're trying to learn R. Been doing some basics. I am trying to do a simple t-test, just to learn that code.
Here's my code, and what's happening:
Code screenshot
I don't get why it says "score" isn't found. It's in the table, and the read.csv code defaults to assuming the first row contains headers. I can't see why it's not "finding" the column for score. I'm sure it's something simple, but would appreciate any help.
You didn't store your imported csv file in a variable. It printed to the console because it had nowhere else to go - it just gets printed and then thrown away. You need to assign it for it to be saved in memory:
my_data_frame <- read.csv("ttest.csv")
Now your data exists in the variable my_data_frame and you can use it by supplying it as the data argument:
t.test(score ~ class, mu=0, alt="two.sided", conf=0.95, var.eg=F, paired=F, data=my_data_frame)
Also, in general, I would recommend using read_csv from the package readr over the default read.csv - it's faster.
Finally, when you ask questions, please provide your code as text, not a picture. You should also provide your data or a toy dataset - you can use the function dput to print code that will create your data, or just provide the csv file or some code that creates toy data.

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.

Resources