library(Biobase)
library(GEOquery)
gds4577 <- getGEO(filename='c:/test/GDS4577_full.soft.gz')
eset <- GDS2eSet(gds4577, do.log2=TRUE)
> eset <- GDS2eSet(gds4577, do.log2=TRUE)
File stored at:
C:\DOCUME~1\sanya\LOCALS~1\Temp\RtmpQtuak0/GPL1261.annot.gzC:\DOCUME~1\sanya\LOCALS~1\Temp\RtmpQtuak0/GPL1261.annot.gz
Error in gzfile(fname, open = "rt") : invalid 'description' argument
In addition: Warning messages:
1: In if (GSEMatrix & geotype == "GSE") { :
the condition has length > 1 and only the first element will be used
2: In if (geotype == "GDS") { :
the condition has length > 1 and only the first element will be used
3: In if (geotype == "GSE" & amount == "full") { :
the condition has length > 1 and only the first element will be used
4: In if (geotype == "GSE" & amount != "full" & amount != "table") { :
the condition has length > 1 and only the first element will be used
5: In if (geotype == "GPL") { :
the condition has length > 1 and only the first element will be used
6: In if (!file.exists(destfile)) { :
the condition has length > 1 and only the first element will be used
7: In download.file(myurl, destfile, mode = mode, quiet = TRUE, method = getOption("download.file.method.GEOquery")) :
only first element of 'url' argument used
8: In download.file(myurl, destfile, mode = mode, quiet = TRUE, method = getOption("download.file.method.GEOquery")) :
only first element of 'destfile' argument used
> eset
Error: object 'eset' not found
what is the matter with my computer?
> sessionInfo()
R version 3.0.2 (2013-09-25)
Platform: i386-w64-mingw32/i386 (32-bit)
locale:
[1] LC_COLLATE=Chinese_People's Republic of China.936 LC_CTYPE=Chinese_People's Republic of China.936
[3] LC_MONETARY=Chinese_People's Republic of China.936 LC_NUMERIC=C
[5] LC_TIME=Chinese_People's Republic of China.936
attached base packages:
[1] parallel stats graphics grDevices utils datasets methods base
other attached packages:
[1] GEOquery_2.28.0 BiocInstaller_1.12.0 affy_1.40.0 Biobase_2.22.0 BiocGenerics_0.8.0
loaded via a namespace (and not attached):
[1] affyio_1.30.0 preprocessCore_1.24.0 RCurl_1.95-4.1 tools_3.0.2 XML_3.98-1.1 zlibbioc_1.8.0
GEOquery currently does not handle the case of the "full_soft" file, a file that is a combination of the GDS expression and the GPL information associated with the GDS. I've put parsing the full_soft format on my TODO list. For the time being, avoiding the "full_soft" file format is what I would recommend, also. Doing so is not a problem since GEOquery will reconstruct the "full_soft" file contents when importing a GDS using the standard GEOquery workflow.
Related
First post, so please be lenient...
problem:
I am trying to use an edges-vector and types vector to use the iGraph function
make_bipartite_graph() in R, however I run into an error concerning Vertex IDs:
Error - At core/misc/bipartite.c:527 : Invalid (negative or too large) vertex id, Invalid vertex id
#types in form of NodesAndType gives the boolean info for all 122 nodes
#whether they belong to nodeSet1 or nodeSet2
> head(NodesAndType[,2])
[1] FALSE FALSE FALSE FALSE FALSE FALSE
> length(NodesAndType[,2])
[1] 122
make_bipartite_graph(types = NodesAndType[,2], edges = EL_vector)
#**edges** in form of the EL_vector gives all edges of the graph in from-to format in one vector
> head(EL_vector)
[1] 1 201 2 201 3 201
> head(NodesAndType[,2])
[1] FALSE FALSE FALSE FALSE FALSE FALSE
> length(NodesAndType[,2])
[1] 122
make_bipartite_graph(types = NodesAndType[,2], edges = EL_vector)
## make_bipartite_graph is throwing thefollowing error
make_bipartite_graph(types = NodesAndType[,2], edges = EL_vector)
>Error in make_bipartite_graph(types = NodesAndType[, 2], edges = EL_vector) :
> At core/misc/bipartite.c:527 : Invalid (negative or too large) vertex id, Invalid vertex id
# the two nodesets are
## nodeset1 (type FALSE for bipartite)
nodeset1 <- 1:103
## nodeset2 (type TRUE for bipartite)
nodeset2 <- 201:211
SessionInfo()
>R version 4.1.2 (2021-11-01)
>Platform: x86_64-w64-mingw32/x64 (64-bit)
>Running under: Windows 10 x64 (build 22000)
>Matrix products: default
>attached base packages:
>[1] stats graphics grDevices utils datasets methods base
>other attached packages:
[1] igraph_1.3.1 dplyr_1.0.7
With make_bipartite_graph, the vertices are defined by the types vector. The number of vertices is the same as the length of types. In your example, you have 122 vertices, but you are referring to vertex ID 201, which is invalid (too large).
I messed up with something but I don't know where to look. My guess is that something happened when I updated some packages in emacs but I don't know which one exactly. Any help would be appreciated Even running a basic command like the following:
\begin{document}
<<test>>=
1+1
#
\end{document}
yield the following error
label: test
Quitting from lines 39-40 (/tmp/tmp.rnw)
Error in data.frame(..., check.names = FALSE) :
arguments imply differing number of rows: 3, 0
In addition: Warning messages:
1: In is.na(res[, 1]) :
is.na() applied to non-(list or vector) of type 'NULL'
2: In is.na(res) : is.na() applied to non-(list or vector) of type 'NULL'
and here is the stack trace:
+ Error in data.frame(..., check.names = FALSE) :
arguments imply differing number of rows: 3, 0
----------------------------------
22: stop(gettextf("arguments imply differing number of rows: %s",
paste(unique(nrows), collapse = ", ")), domain = NA)
21: data.frame(..., check.names = FALSE)
20: cbind(deparse.level, ...)
19: cbind(z[, c("line1", "col1", "line2", "col2", "text")], merge_cmd(z,
markup))
18: (if (fallback) hi_naive else hilight_one)(code, format, markup,
escape_fun)
17: highr::hilight(x, format, prompt = options$prompt, markup = opts$markup)
16: hilight_source(x, "latex", options)
15: (knit_hooks$get("source"))(src, options)
14: wrap.source(X[[1L]], ...)
13: FUN(X[[1L]], ...)
12: lapply(x, wrap, options)
11: wrap.list(res, options)
10: wrap(res, options)
9: unlist(wrap(res, options))
8: block_exec(params)
7: call_block(x)
6: process_group.block(group)
5: process_group(group)
4: withCallingHandlers(if (tangle) process_tangle(group) else process_group(group),
error = function(e) {
setwd(wd)
cat(res, sep = "\n", file = output %n% "")
message("Quitting from lines ", paste(current_lines(i),
collapse = "-"), " (", knit_concord$get("infile"),
") ")
})
3: process_file(text, output)
2: knit(input, output = output, envir = envir, quiet = quiet, encoding = encoding)
1: knit2pdf("tmp.rnw")
Update
## R version 3.1.2 (2014-10-31)
## Platform: x86_64-redhat-linux-gnu (64-bit)
## locale:
## [1] LC_CTYPE=en_US.utf8 LC_NUMERIC=C
## [3] LC_TIME=en_US.utf8 LC_COLLATE=en_US.utf8
## [5] LC_MONETARY=en_US.utf8 LC_MESSAGES=en_US.utf8
## [7] LC_PAPER=en_US.utf8 LC_NAME=C
## [9] LC_ADDRESS=C LC_TELEPHONE=C
## [11] LC_MEASUREMENT=en_US.utf8 LC_IDENTIFICATION=C
## attached base packages:
## [1] stats graphics grDevices utils datasets methods base
## other attached packages:
## [1] knitr_1.10.5
## loaded via a namespace (and not attached):
## [1] compiler_3.1.2 evaluate_0.7 formatR_1.2 highr_0.5 stringr_1.0.0
## [6] tcltk_3.1.2 tools_3.1.2
Ran into the same problem today. For me this was fixed by upgrading the knitr packge from version 1.10.5 to version 1.11., the evaluate package from version 0.7 to version 0.7.2, the formatR package from version 0.9 to version 1.2, and the highr package from version 0.2.1 to version 0.5.
I upgraded these in order and it only worked after upgrading highr, so I suspect that this is the culprit.
Sigh, looks like it's probably time to update.packages().
My code runs fine but fails in a package
I boiled it down to
wtf<-function(r)
{
require(raster)
stopifnot(class(r) == "RasterLayer")
return(as.matrix(r))
}
When sourced, everything works fine. When the function is part of a package, it fails. It nicely runs in debug mode though, step by step.
library(mypackage)
r <- raster(ncol=6, nrow=6)
r[] <- runif(ncell(r),0,1)
extent(r) <- matrix(c(0, 0, 6, 6), nrow=2)
wtf(r)
# Error in as.vector(data) :
# no method for coercing this S4 class to a vector
# Traceback
# 5 as.vector(data)
# 4 array(x, c(length(x), 1L), if (!is.null(names(x))) list(names(x),
# NULL) else NULL)
# 3 as.matrix.default(r)
# 2 as.matrix(r) at terrain.R#7
# 1 wtf(s)
I'm a bit puzzeled as to why this happens and to how proceed.
The build went fine, the check went clean, so what is going on?
What would be the next question to ask and explore in order to solve the problem?
R version 3.1.1 (2014-07-10)
Platform: x86_64-apple-darwin10.8.0 (64-bit)
locale:
[1] en_GB.UTF-8/en_GB.UTF-8/en_GB.UTF-8/C/en_GB.UTF-8/en_GB.UTF-8
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] raster_2.3-0 spdep_0.5-77 Matrix_1.1-4 minerva_1.4.1 gdata_2.13.3 rgdal_0.9-1 sp_1.0-15
loaded via a namespace (and not attached):
[1] boot_1.3-11 coda_0.16-1 deldir_0.1-5 grid_3.1.1 gtools_3.4.1 lattice_0.20-29 LearnBayes_2.15 MASS_7.3-33 nlme_3.1-118 parallel_3.1.1 splines_3.1.1 tools_3.1.1
The traceback shows that the default as.matrix is used, rather than the raster variant. I believe this problem goes away if you add this line to your Namespace file:
import(raster)
Or when you are explicit about which as.matrix you want:
wtf <- function(r) {
stopifnot(inherits(r, "RasterLayer"))
raster::as.matrix(r)
}
Rather than 'manually' testing for class membership, you might consider a more formal (S4) approach:
if (!isGeneric("wtf")) {
setGeneric("wtf", function(x, ...)
standardGeneric("wtf"))
}
setMethod("wtf", signature(x='RasterLayer'),
function(x, ...) {
raster::as.matrix(x)
}
)
I am applying similar add.distribution rule as in the luxor-demo while my strategy has only a long position.
The whole strategy works, but when applying a parameterset I get following error:
TakeProfitLONG 47 0.047
TakeProfitLONG 47 0.047 result of evaluating expression:
simpleError in param.combo[[param.label]]: subscript out of bounds
got results for task 47 numValues: 47, numResults: 47, stopped: FALSE
returning status FALSE evaluation # 48: $param.combo
I am trying to run a distribution on a simple takeProfit rule (get same result from stopLoss or trailingStop):
.use.takeProfit = TRUE
.takeprofit <- 2.0/100 # actual
.TakeProfit = seq(0.1, 4.8, length.out=48)/100 # parameter set for optimization
## take-profit
add.rule(strategy.st, name = 'ruleSignal',
arguments=list(sigcol='signal.gt.zero' , sigval=TRUE,
replace=FALSE,
orderside='long',
ordertype='limit',
tmult=TRUE,
threshold=quote(.takeprofit),
TxnFees=.txnfees,
orderqty='all',
orderset='ocolong'
),
type='chain',
parent='EnterLONG',
label='TakeProfitLONG',
enabled=.use.takeProfit
)
I am adding the distribution as follows:
add.distribution(strategy.st,
paramset.label = 'TakeProfit',
component.type = 'chain',
component.label = 'TakeProfitLONG',
variable = list(threshold = .TakeProfit),
label = 'TakeProfitLONG'
)
and apply the set:
results <- apply.paramset(strategy.st, paramset.label='TakeProfit', portfolio.st=portfolio.st, account.st=account.st, nsamples=.nsamples, verbose=TRUE)
From my limited debugging it seems that the parameterset is a simple vector whereas in the apply.paramset following function fails:
results <- fe %dopar% { ... }
Here I am too new to R as i am only 4 weeks looking into this, but possibly a call to:
install.param.combo <- function(strategy, param.combo, paramset.label)
might cause the error?
Have to apologize as I am to new, but did anyone encounter this or could help how to apply a distribution to only one item in a long only strategy?
Many thanks in advance!
EDIT 1: SessionInfo()
R version 3.1.2 (2014-10-31)
Platform: i486-pc-linux-gnu (32-bit)
locale:
[1] C
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] lattice_0.20-29 iterators_1.0.7 downloader_0.3
[4] quantstrat_0.9.1665 foreach_1.4.2 blotter_0.9.1644
[7] PerformanceAnalytics_1.4.3574 FinancialInstrument_1.2.0 quantmod_0.4-3
[11] TTR_0.22-0.1 xts_0.9-7 zoo_1.7-12
loaded via a namespace (and not attached):
[1] codetools_0.2-9 compiler_3.1.2 digest_0.6.7 grid_3.1.2 tools_3.1.2
This is the same bug as # 5776. It was fixed for "signal" component types, but not for "chain". It should now be fixed as of revision 1669 on R-Forge.
I am trying to read a .txt file, with Hebrew column names, but without success.
I uploaded an example file to:
http://www.talgalili.com/files/aa.txt
And am trying the command:
read.table("http://www.talgalili.com/files/aa.txt", header = T, sep = "\t")
This returns me with:
X.....ª X...ª...... X...œ....
1 12 97 6
2 123 354 44
3 6 1 3
Instead of:
אחת שתיים שלוש
12 97 6
123 354 44
6 1 3
My output for:
l10n_info()
Is:
$MBCS
[1] FALSE
$`UTF-8`
[1] FALSE
$`Latin-1`
[1] TRUE
$codepage
[1] 1252
And for:
Sys.getlocale()
Is:
[1] "LC_COLLATE=English_United States.1252;LC_CTYPE=English_United States.1252;LC_MONETARY=English_United States.1252;LC_NUMERIC=C;LC_TIME=English_United States.1252"
Can you suggest to me what to try and change to allow me to load the file correctly ?
Update:
Trying to use:
read.table("http://www.talgalili.com/files/aa.txt",fileEncoding ="iso8859-8")
Has resulted in:
V1
1 ?
Warning messages:
1: In read.table("http://www.talgalili.com/files/aa.txt", fileEncoding = "iso8859-8") :
invalid input found on input connection 'http://www.talgalili.com/files/aa.txt'
2: In read.table("http://www.talgalili.com/files/aa.txt", fileEncoding = "iso8859-8") :
incomplete final line found by readTableHeader on 'http://www.talgalili.com/files/aa.txt'
While also trying this:
Sys.setlocale("LC_ALL", "en_US.UTF-8")
Or this:
Sys.setlocale("LC_ALL", "en_US.UTF-8/en_US.UTF-8/C/C/en_US.UTF-8/en_US.UTF-8")
Get's me this:
[1] ""
Warning message:
In Sys.setlocale("LC_ALL", "en_US.UTF-8") :
OS reports request to set locale to "en_US.UTF-8" cannot be honored
Finally, here is the > sessionInfo()
R version 2.10.1 (2009-12-14)
i386-pc-mingw32
locale:
[1] LC_COLLATE=English_United States.1255 LC_CTYPE=English_United States.1252 LC_MONETARY=English_United States.1252 LC_NUMERIC=C
[5] LC_TIME=English_United States.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
loaded via a namespace (and not attached):
[1] tools_2.10.1
Any suggestion or clarification will be appreciated.
Best,
Tal
I would try passing parameter fileEncoding to read.table with a value of iso8859-8.
Use iconvlist() to get an alphabetical list of the supported encodings. As I saw here Hebrew must be part 8 of ISO 8859.
I've tried #George Donats answer, but couldn't make it work. So I wanted to suggest another possibility for future reference.
I couldn't find the file online, so I've recreated a txt file like your using TAB as a seperator. You can load it into R with the Hebrew text using a connection. It is demonstrated below:
con<-file("aa.txt",open="r",encoding="iso8859-8") ##Open a read-only connection with encoding fit for Hebrew (iso8859-8)
Than you can load it into R with your code, using con variable as the file input, code described here:
data<-read.table(con,sep="\t",header=TRUE)
Browsing into the data variable gives the following results:
str(data)
'data.frame': 3 obs. of 3 variables:
$ אחת : int 6 44 3
$ שתיים: int 97 354 1
$ שלוש : int 12 123 6
> data$אחת
[1] 6 44 3