xuzhougeng / binmapr Goto Github PK
View Code? Open in Web Editor NEWR package for binmap
R package for binmap
When I executed the "batchCallGeno" function as flow, an error occurred: operator is invalid for atomic vectors.
geno_out <- batchCallGeno(GT_flt, CHROM = CHROM,
pos.start = 7, fix.size = 10)
This error Can't be solved by translating GT_flt(matrix) to dafa.frame.
The problem is created by the "batchCallGeno" function,
geno <- callWindowGeno(x, window.size = window.size,
low = low.count, high = high.count)
## Fix the potential error
geno_fix <- fixGenoError(geno, fix.size = fix.size)
After "callWindowGeno", the geno is a list. But the "fixGenoError" function tries to quote the colnames (geno, CHROM and ind.name) that don't exist in geno. And the "callWindowGeno" function doesn't generate these colnames.
fixGenoError <- function(x, fix.size = 10 ){
geno <- x$geno
chroms <- x$CHROM
samples <- x$ind.name
callWindowGeno <- function(x, window.size = 15,
low = 6, high = 24){
splitSNP <- split(x, ceiling(seq_along(x)/window.size))
batchSNP <- sapply(seq_along(splitSNP), function(x){
snp_num <- length(splitSNP[[x]])
start_name <- names(splitSNP[[x]][1])
end_name <- names(splitSNP[[x]][snp_num])
chr_name <- strsplit(start_name,"_",fixed = TRUE)[[1]][1]
start_pos <- as.numeric(strsplit(start_name,"_",fixed = TRUE)[[1]][2])
end_pos <- as.numeric(strsplit(end_name,"_",fixed = TRUE)[[1]][2])
total <- sum(splitSNP[[x]], na.rm = TRUE)
names(total) <- paste(chr_name, floor((start_pos + end_pos) / 2) , sep = "_")
return(total)
})
geno <- ifelse(batchSNP < low, 0, ifelse(batchSNP > high ,2 , 1))
return(geno)
}
install.packages("binmapr")
Installing package into ‘/home/R/x86_64-pc-linux-gnu-library/4.0’
(as ‘lib’ is unspecified)
Warning in install.packages :
package ‘binmapr’ is not available for this version of R
Thanks
When I run the example you provide, it occurred an error?
The operation process is as follows:
AD <- matrix(data = c("30,1","1,30","0,0","15,15"), nrow = 2)
row.names(AD) <- c("chr1_1","chr1_100")
colnames(AD) <- c("A","B")
freq <- calcFreqFromAd(AD)
Error: $ operator is invalid for atomic vectors
I have tried trun the matrix to data.frame, but it doesn't work. I wish if you can help me to solve this problem.
freq <- calcFreqFromAd(ad_flt, min.depth = 10, max.depth = 100)
错误: $ operator is invalid for atomic vectors
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.