Reputation: 809
I'm having a weird issue with R.
Basically, I am following this analysis pipeline in order to understand how it works. At some point (right after the first introductory paragraph, the last few lines of the history) I find this piece of code:
#--- clustering ---#
for (n in names(all.sce)) {
g <- buildSNNGraph(all.sce[[n]], k=10, use.dimred='PCA')
clust <- igraph::cluster_walktrap(g)$membership
colLabels(all.sce[[n]]) <- factor(clust)
}
that calls this function colLabels which throws a very weird error:
Error in colLabels(allEnsembl[[n]]) <- factor(clust) : cant find the
function "colLabels<-"
Now, since I am working with a specific kind of data, i.e. single cell data (bioinformatics here), I've looked into this function and it seems to be part of this package called SingleCellExperiment, which I can load successfully before launching the above piece of code.
Once I encountered the error I looked into the R help which can't actually find anything:
> help(colLabels)
No documentation for 'colLabels' in specified packages and libraries: you could try '??colLabels'
> ??colLabels
No vignettes or demos or help files found with alias or concept or title matching 'colLabels' using fuzzy matching.
Problem is...why does the error point to a function (apparently) called colLabels<-?
EDIT: other functions from the mentioned package, i.e. SingleCellExperiment, work and help pages are available.
EDIT 2: I've imported the required library. I also looked into the version I've installed and it seems to be an issue related to the versions. Using sessionInfo()
R tells me I've version 1.8.0 which fits with what stated in the Bioconductor website. The packages version available and also the pdf documentation refers to 1.8.0. BUT I've noticed that in the previous link I've attached I was referring to a development version...probably I need to install it (?)
EDIT 3: ok, I have other issues now. The one in the question was an issue related to the package version since the official SingleCellExperiment was 1.8.0 while the doc I found was related to 1.9.3 which was a development version. Once installed, the help for the function works, but the function itself do not.
sessionInfo()
now states that I have the version 1.9.3 but other functions do not work anymore so, I dont know.
Upvotes: 1
Views: 556
Reputation: 121
The colLabels function was only added in version 1.9.3. This will come out with the next Bioconductor release at the end of this month, see here. In the meantime, you can either:
Install R 4.0.0 and start using BioC-devel to get access to 1.9.3, or Just get and set values from sce$label, which does the same thing.
These are quotes from Aaron Lun's (SingleCellExperiment package developper) Git Memory.
Upvotes: 2
Reputation: 992
This is the default R
behaviour.
If you call a not imported or non-existing function, the error message looks like:
> non_existing_function(x)
Error in non_existing_function(x) :
could not find function "non_existing_function"
If you call a not imported or non-existing function together with an assignment operator, the error message looks like:
> non_existing_function(x) <- y
Error in non_existing_function(x) <- y :
could not find function "non_existing_function<-"
You have to import the SingleCellExperiment
package to be able to use colLabels
:
library(SingleCellExperiment)
Update: You definitely have to use the dev version (1.9.3). If you check the manual for the current stable (1.8.0), there is no function colLables
there, but there is in the manual for dev version (1.9.3).
Upvotes: 2