I have a lot of .net files, and the package tutorial says it is possible to use this format with sna.
My error message is:
> Error in FUN(X[[1L]], ...) : as.edgelist.sna input must be an
> adjacency matrix/array, edgelist matrix, network, or sparse matrix, or
> list thereof.
How can I open .net files with sna package in R? I browsed the net but I couldn't find any helpful information to my problem.
I have no problem with using package igraph, but there are some pros to use package sna, too.
Thank you in advance.
P.S. I tried to read pajek with library(network):
b1<- read.paj("15.net")
Warning message:
In readLines(file, 1, ok = TRUE) : incomplete final line found on '15.net'
If it works with 'igraph', do it with 'igraph'. Then convert the data to a form acceptable by functions in the 'sna' package. For example with asNetwork function from package 'intergraph' you can convert igraph object to a network object (package 'network'), which you can use with 'sna'.
Related
I tried to run the code in Chapter 7 Data mining with R learning with case study book but I got an error in following line:
rankWorkflows(svm, maxs = TRUE)
The error was:
Error in as.character.default(X[[i]], ...) : no method for coercing
this S4 class to a vector
Then I searched on the internet and found following solution:
importMethodsFrom(GenomicRanges, as.data.frame)
and again again I got a new error:
Error: could not find function "importMethodFrom"
I searched a lot but I got nothing :(
You can try using library(sos) to find the packages where your function is located.
library(sos)
findFn("replaceherewithyourfunction")
Based on the answer of #Bea, there does not seem to be a importMethodsFrom anywhere in R. My guess is you found the call in a NAMESPACE file. Those files have different syntax than normal R scripts.
If you want to load a specific function from an R package (rather than all functions from a package), you can use libraryname::functionname instad of functionname in your code. In your case, replace as.data.frame with GenomicRanges::as.data.frame
If this does not work (for example because you don't have as.data.frame anywhere in your code), you can also load the whole GenomicRanges library with library(GenomicRanges)
I am trying to load a file from the spanish building census (any of the files there will serve as an example, I'm using the 03001-ADSUBIA buildings one).
I have tried the read.gml function from the Multiplex package and get the following error:
read.gml("A.ES.SDGC.BU.03001.building.gml")
Error in which(("node" == arx) == TRUE)[1]:which(("edge" == arx) == TRUE)[1] :
NA/NaN argument
Then I tried the read.graph from the igraph package and also got an error:
read.graph("A.ES.SDGC.BU.46900.building.gml", format=c("gml"))
Error in .Call("R_igraph_read_graph_gml", file, PACKAGE = "igraph") :
At foreign.c:1127 : Parse error in GML file, line 1 (syntax error, unexpected STRING, expecting $end), Parse error
What am I doing wrong, and what can I do to fix it?
igraph and multiplex do not work because that is a different GML: Graph Modelling Language, as the name suggests, is for graphs (or networks). Your GML is Geography Markup Language.
Found an alternative on this post. However I would like to know why specific packages like multiplex or igraph cannot get the job done properly...
Code:
llayer<-ogrListLayers("A.ES.SDGC.BU.03001.building.gml")[1]
a<- readOGR(dsn="A.ES.SDGC.BU.46900.building.gml", layer=llayer, encoding = "UTF-8")
I have successfully used GEPHI to open gml files, and then use GEPHI'S export function (menu driven) to create 'new' gml files that open with igraph in R.
Details about GEPHI and the gml file definition are here.
I try to load a .mat file using the R.matlab library. When I run:
x <- readMat("MPL.mat")
I get this error however.
Error in mat5ReadTag(this) :
Unknown data type. Not in range [1,19]: 18569
In addition: Warning message:
In readMat5Header(this, firstFourBytes = firstFourBytes) :
Unknown MAT version tag: 512. Will assume version 5.
Anybody who experienced this and has a way to deal with this?
Im familiar with this post: R.matlab/readMat : Error in readTag(this) but alternatives ways didnt work for me...
The problem is related to how is saved your "MPL.mat". If you save by default in MATLAB, it probably won't work using R.matlab in R.
When I saved my .mat object in '-v7' or '-v6' i did not have problems, but the R.matlab documentation suggest to save in '-v6' (Pag.25 in R.matlab package). For example, I saved 2 matrices (A and B) in 'MPL.mat'.
save('MPL.mat','A', 'B', '-v7')
I could read in R:
require(R.matlab)
data <- readMat("MPL.mat")
View(data$A)
View(data$B)
I'm having trouble locating the packages for corhelp in R. This is what I get.
AdjMatHARD=abs(corhelp[restConnectivity,restConnectivity])>0.65+0.0
# Error: object 'corhelp' not found
Assuming you're following the code from YEAST
Gene Co-expression Network Analysis R Tutorial, corhelp is a variable defined in the code
corhelp=cor(datExpr,use="pairwise.complete.obs")
just search that page for corhelp to find it.
I am trying to read probes from a dat file, put them in a vector then put the vector into a subset to be able to concatenate more data to it and write it in a CSV file. Here my piece of code:
library(Biobase)
library(affy)
affys <- read.csv("address of my dat file")
affys_vec <- as.vector(affys)[,1]
exprs(eset)[affys_vec,] -> sub.set
write.csv(sub.set,file="subset.csv")
However when I reach to the : exprs(eset)[affys_vec,] -> sub.set
I get the following error message:
** Error in exprs(eset) :
error in evaluating the argument object' in selecting a method for function 'exprs':
Error: object 'eset' not found **
Are there any suggestions please?
Thanks,
pqtm
See the vignette An introduction to Biobase and ExpressionSets available on your computer, once Biobase is installed, as
vignette(package="Biobase", "ExpressionSetIntroduction")
But the idea is that you have created eset by pre-processing some CEL or other vendor-specific files. How you pre-process those depends on what your files are, maybe with affy or oligo or lumi, or from a public repository using a package like ArrayExpress or GEOquery Or perhaps you're using limma and have no need for an expression set.
The Bioconductor web site and mailing list provides a lot more information.