How to solve the following error running rmcorr in R: Error in isa(Participant, "character") : could not find function "isa" - r

I have the data in long format, with subject (numbered 1 to 124), Day, measure1, and measure2. There are about 14 repeating measures per subject. I want to run rmcorr to see if there is a correlation between measure1 and measure2 across all subjects. I used the code:
rmcorr(participant, measure1, measure2, data)
I get:
Error in isa(Participant, "character") : could not find function "isa"
I have used the same syntax before without any errors arising!

I've seen this error with older versions of R and strangely with 4.0.4, but only in Linux. I would try updating R. Hopefully that works!

The isa() function is a function in the base library (https://stat.ethz.ch/R-manual/R-devel/library/base/html/class.html), which is not part of all versions of R (use "?class()" to see if your version includes it).
In my case it worked to replace it with the "is()"-function, which does (in most cases, see documentation) pretty much the same. Just do
library(rmcorr)
isa = is
rmcorr(your input)
and you will be fine.
Best regards,
JF

Related

truthTable in Rstudio Error: incorrect outcome specification

I was trying to do a QCA analysis of sufficeny in RStudio 4.1.3. using truthTable command. By running the code i get Error: wrong outcome specification. The outcome is written correctly. When I do an analysis of necessity with superSubset code everything works fine. Everything is coded numeric but it does not work with bivariate callibration either.
> ttCO21 <- truthTable( data = mydata, outcome = "CO21",
+ conditions = "GENDG1, FDI1, GDP1",
+ sort.by="incl, n", show.cases = TRUE, complete = TRUE)
**Error: Incorrect outcome specification.**
I had the same issue today and the solution was to delete any unnecessary columns (or create a new dataframe). I left only the calibrated conditions and outcome, because when I found this error, the raw data was in the same df, even if was not using it in the truthTable() command.
Because of the 3 hours i wasted on this problem i'll share my situation and solution. I had the exact same problem. creating a new df did not help, nor did removing unnecessary colums (wouldn't make sense anyway). Completely reinstalling en reloading the QCA package did work for me. Hope this helps someone.
you can try "comma" instead of "dot" (in “decimal") when you import file

ViSEAGO tutorial: visualising topGO object

Earlier, I had posted a question and was able to load in my data successfully and create a topGO object after some help. I'm trying to visualise GO terms that are significantly associated with the list of differentially expressed genes that I have from mouse RNA-seq data.
Now, I'd want to raise a concern about ViSEAGO's tutorial. The tutorial initially specifies loading two files: 'selection.txt' and 'background.txt'. The origin of these files is not clearly stated. However, after a lot of digging into topGO's documentation, I was able to find the datatypes for each of the files. But, even after following these, I have a problem running the following code. Does anyone have any insights to share?
WORKING CODE:
mysampleGOdata <- new("topGOdata",
description = "my Simple session",
ontology = "BP",
allGenes = geneList_new,
nodeSize = 1,
annot = annFUN.org,
mapping="org.Mm.eg.db",
ID = "SYMBOL")
resultFisher <- runTest(mysampleGOdata, algorithm = "classic", statistic = "fisher")
head(GenTable(mysampleGOdata,fisher=resultFisher),20)
myNewBP<-GenTable(mysampleGOdata,fisher=resultFisher)
PROBLEMS:
> head(myNewBP,2)
GO.ID Term Annotated Significant Expected fisher
1 GO:0006006 glucose metabolic process 194 12 0.19 1.0e-19
2 GO:0019318 hexose metabolic process 223 12 0.22 5.7e-19
> ###################
> # merge results
> myBP_sResults<-ViSEAGO::merge_enrich_terms(
+ Input=list(
+ condition=c("mysampleGOdata","resultFisher")
+ )
+ )
Error in setnames(x, value) :
Can't assign 3 names to a 2 column data.table
> myNewBP<-GenTable(mysampleGOdata,fisher=resultFisher)
> ###################
> # display the merged table
> ViSEAGO::show_table(myNewBP)
Error in ViSEAGO::show_table(myNewBP) :
object must be enrich_GO_terms, GO_SS, or GO_clusters class objects
According to the tutorial, the printed table contains for each enriched GO terms, additional columns including the list of significant genes and frequency (ratio of the number of significant genes to the number of background genes) evaluated by comparison. I think I have that, but it's definitely not working.
Can someone see why? I'm not very clear on this.
Thanks!
I think you try to circumvent an error you made at the beginning. You receive the error due to the fact that you did not use the wrapper function from the ViSEAGO package. As you stated in your last question, you had initial problems formatting your data.
Here are some tips:
The "selection" file is a character vector with your DEGs names or IDs. I recommend using EntrezID's.
The "Background" file is a character vector with known genes. I recommend using EntrezID's as well. You can easily generate this character vector with:
background=keys(org.Hs.eg.db, keytype ='ENTREZID').
With these two files, you can easily proceed to the next steps of the package as described in the vignette.
# connect to EntrezGene
EntrezGene<-ViSEAGO::EntrezGene2GO()
# load GO annotations from EntrezGene
# with the add of GO annotations from orthologs genes (see above)
#id = "9606" = homo sapiens
myGENE2GO<-ViSEAGO::annotate(id="9606", EntrezGene)
BP<-ViSEAGO::create_topGOdata(
geneSel = selection, #your DEG vector
allGenes = background, #your created background vector
gene2GO=myGENE2GO,
ont="BP",
nodeSize=5
)
classic<-topGO::runTest(
BP,
algorithm ="classic",
statistic = "fisher"
)
# merge results
BP_sResults<-ViSEAGO::merge_enrich_terms(
Input=list(
condition=c("BP","classic")
)
)
You should get a merged list of your enriched GO terms with the corresponding statistical tests you prefer.
I have faced this problem recently, it was very frustrating. In my case the whole issue seemed to be related to the package version I was using.
I used conda to install ViSEAGO. Nevertheless, R's version in my conda environment was a bit old (i.e. 3.6.1 to be specific). Therefore, when installing ViSEAGO with conda, the version 1.0.0 of the package was installed. Please note that the most recent version of ViSEAGO is 1.4.0.
Therefore, I created a conda environment with R version 4.0.3, and repeated the procedure to install ViSEAGO by using conda. When doing this, ViSEAGO's 1.4.0 version was installed, and everything went fine.
I've tried to backtrack the error, and only find one thing: in the older ViSEAGO version, the function Custom2GO loaded tables with 4 columns; in the most recent version it admits 5 columns (the new one being 'gene_symbol'). I think this disagreement might be part of the issue, as the source code of the function merge_enrich_terms seems to deal with the columns 'gene_id' and 'gene_symbol' at some point, but I'm not sure.
Hope you find my comment helpful!
Cheers,
Mauricio

Fatal error when runing es() function in R

es function in smooth package has a weird behavior for some short time-series. Here is a case:
require(smooth) # version 2.4.7
#create two time series of length 10
vec1_ts<-ts(c(36,24,51,7,7,77,1,29,19,2),start=c(2016,1),frequency=12)
vec2_ts<-ts(1:10,start=c(2016,1),frequency=12)
#this works:
es(vec1_ts)
#but this doesn't:
es(vec2_ts)
# another non-working example with a shorter length
vec3_ts<-ts(c(23,5,4,12,2,5),start=c(2016,1),frequency = 12)
es(vec3_ts)
I got a "R encountered a fatal error" message, and then forced to terminate the session when running es for the second time-series.
This looks like a bug in the function of that package. Can you, please, submit the bug here: https://github.com/config-i1/smooth/issues
The StackOverflow is not for solving problems of specific packages, it is for the solution of more general problems.

Error in `freeParam` in fitting of normal copula [R]

I am using R version 3.3.2 and the package copula version 0.999-15 to evaluate the fitting of the normal copula to my data. My data and code are:
Data: https://www.dropbox.com/s/tdg8bfzmy4nd1dd/jumps.dat?dl=0
library(copula)
data <- read.csv(file="jumps.dat", head=F, sep="")
cop_model <- ellipCopula("normal", dim = 2)
m <- pobs(as.matrix(data))
fitCopula(cop_model, m, method = 'mpl')
After I run the code I receive the following error:
Error in `freeParam<-`(`*tmp*`, value = estimate) : the length of 'value' is not equal to the number of free parameters
Calls: fitCopula ... fitCopula.ml -> fitCopStart -> fitCopula.icor -> freeParam<-
Execution halted
I have no idea what is happening here. The fitting for Clayton and Gumbel is pretty fine. Searching for similar errors in the web, I have found nothing. Reading the documentation (https://www.rdocumentation.org/packages/copula/versions/0.999-15/topics/fitCopula?) for some specificity for ellipCopula, I have found an specific option for posDef, but it did not returns any solution at all.
Old question, but I found this, so will share my solution.
Try to run the following, this is a minimum working example:
library(copula)
print("-----------")
mycop <- ellipCopula("normal", dim=4)
data <- matrix(runif(400), nrow=4)
fitCopula(mycop, t(data))
print("-----------")
For me, this works fine if I open R and type in the lines one by one, but fails if I run as a script with Rscript. The solution is that you need library(methods) as well.
For some reason this worked with copula v0.999-v14, but was broken by v0.999-v16. Alas.

Error with src() command in R

Yesterday I posted this question on Stats Exchange and based on the response I got, I decided to do some analysis using R's src() function. It's part of the "sensitivity" package.
I installed the package with no trouble, and then tried the following command:
sens <- src(seminars, REV, rank=TRUE, nboot=100)
sens is a new variable to store the results of the test
seminars is a data frame that I imported from a CSV file using the read.csv() command
REV is the name of a variable/column in seminars and my desired response variable
When I ran the command, I got the following error:
Error in data.frame(Y = y, X) : object 'REV' not found
Any thoughts?
From the documentation of src
y: a vector containing the responses corresponding to the design
of experiments (model output variables).
The input needs to be a vector (apparently) and you're attempting to pass in a name (and not even quoting the name at that). Since REV isn't defined (I'm guessing due to the error message) in the global environment it doesn't know what to do.
From reading the documentation it sounds like what you want to do is pass sensitivity[,-which(colnames(sensitivity) == "REV")] (just the design matrix - you don't want to include the responses) in as x and sensitivity[,"REV"] in as y.
This error is linked to the fact that the data.frame X=seminars include factors with 0 value, which produce an error while constructing the regression coefficient. You can first remove them as they don't contribute to the variance of the output.

Resources