Comments (7)
Reading in as a sqldf
does not work. Slower at least by a factor of 10.
for(k in 1:5){
if(k == 1){
f = file(paste0(path, "chr1_block_", i, "_perm_", j, "_k_", k, ".controls.gen"), h = F, sep = " "))
sqldf("select * from f", dbname = tempfile(), file.format = list(header = T, row.names = F)) -> gen
} else if(k != 1){
f = file(paste0(path, "chr1_block_", i, "_perm_", j, "_k_", k, ".controls.gen"), h = F, sep = " "))
sqldf("select * from f", dbname = tempfile(), file.format = list(header = T, row.names = F)) %>% data.table::merge(gen, ., by = "V1:V5") %>% cbind(gen, .) -> gen
}
}
from corge.
Read lines was at least 100 times slower.
inputFile <- "../inst/extdata/toy.gen"
system.time({
con <- file(inputFile, open = "r")
out <- data.table(ID = 1:1000)
while (length(oneLine <- readLines(con, n = 1, warn = FALSE)) > 0) {
myVector <- (strsplit(oneLine, " "))
myVector <- as.vector(as.factor(unlist(myVector)))
foreach(row = 1:nrow(gen)) %:% foreach(i = seq(6,((length(myVector)-2)),by=3), .combine = c) %do% {
myVector <- gen[row,]
j <- i + 1
h <- i + 2
one <- myVector[i]
two <- myVector[j]
three <- myVector[h]
final <- NA
if (one > 0.9) {
final <- 0
} else if (two > 0.9) {
final <- 1
} else if (three > 0.9) {
final <- 2
} else {
final <- NA
}
final
}
out[, myVector[3] := vec, with = FALSE] -> out
message(paste0(ncol(out)))
}
from corge.
The above was also slower when
library(doParallel)
makeCluster(8)
Then %dopar%
.
from corge.
Reading lines one at a time with coRge::gen2R
was really bad.
from corge.
Chaining rows together with %:%
was equally disastrous. Don't go down this path.
from corge.
foreach
with .combine = 'rbind()'
and .combine = 'c'
was just insanely slow.
from corge.
Issue #19 might do it
from corge.
Related Issues (20)
- base::for => doMC::foreach [Oxford to R format conversion]
- data.table::fread() / coR-ge::gen2r() => readlines() + foreach::dopar() HOT 3
- Adjust p values by grouping vector [correct() and analyze()]
- Vignette
- Import shell scripts from inst/bash in sim.gen()
- Circumvent need for coRge::gen2r() HOT 1
- snps out of scope in coRge::phen
- Non finite elements introduced in effect size calculation
- Clean up namespace conflict warnings with @ImportFrom HOT 2
- Remedy .GlobalEnv() workaround for `samp` HOT 1
- Export group and group_name arguements
- CentOS 6 Compatibility (g++ < 4.6) HOT 1
- Unsigned to signed int comparison [-wSign-compare] HOT 1
- [v0.6.3.9000] Singular Matrices in c(1, gen) HOT 1
- [v0.6.4.9000] Deprecate i and j args in favour of path to file / dir
- Add in gene "mode"
- Logging with futile.logger and pass up threshold
- Vectorize SNPTEST2R.R
- Sub Script function HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from corge.