Comments (12)
You should start from the warning messages. X.sub
is probably shorter than K1[, 2]
.
Also, ind
spans the column indices by default in big_apply()
, but here you're using it for the rows.
from bigstatsr.
Thanks for your quick reply! Actually,I have edited my code to calculate each row's result,but the result is also NA.
colmeans <- big_apply(X1, ind = rows_along(X),function(X, ind) {
X.sub <- X[ind,1]
K1<-map_dfr(unique(X[,1]),function(i){
S1 <-mean(Y[which(X[,1]==i),1])
data.frame(Value=S1,clu=i)
})
a<-K1[which(K1[,2]==X.sub),1]
b<-min(K1[which(K1[,2]!=X.sub),1])
si=(b-a)/max(b,a)
return(si)
}, a.combine = 'c')
from bigstatsr.
Yes, cf. my first comment.
from bigstatsr.
Sorry for bothering again.When I test single numble (ind=1), my code works.But I put the code into the big_apply,the results are NA. What is the problem? Does the R algorithm not work in big_apply? Thanks.
from bigstatsr.
No, your code doesn't work when using ind <- 1
.
It is just that X.sub
is of length 1 and gets automatically recycled to match the size of K1[, 2]
.
Which is probably not what you want.
from bigstatsr.
You need to think about what you are trying to achieve here.
If I had to guess, I would say that you need to subset K1[ind, 2]
.
from bigstatsr.
Thanks for your reply. In order to find out the problem,i try a simple test as following.I think it may be that I didn't input one of the two variables, Y, so there is no result. But after I rewrite the code like your multivariate format (https://privefl.github.io/bigstatsr/articles/big-apply.html) , there is still no result output, which is very wired.Could you give me some suggestions? Thanks.
from bigstatsr.
- Properly passing other variables as arguments of the function is necessary only when using parallelism.
- Doing
mean(Y[-ind, ])
is very odd (especially the minus). What are you trying to achieve here (in simple English)? - What do you have for
summary(Y)
?
from bigstatsr.
'ind' means the row number, mean(Y[-ind, ]) means that the matrix in this row will be removed, and the mean of new matrix will be calculated.
'Summary(Y)' shows as following.
from bigstatsr.
-
I didn't get that
Y
was also an FBM. Thensummary(Y[])
. -
You understand that
ind
is usually a vector of multiple indices, not just one, right? -
And you want the full
mean()
of the matrix? Not something like therowMeans()
?
from bigstatsr.
Yes, I probably understand what you mean. I tested the simple example above to know how to rewrite the a.FUN in big_apply step by step.My original R code is below. Because the matrix is too big and it runs too slowly, I want to realize this function by using big_apply.cluster_info and dist, which are the original matrix. Their row names and number of rows are the same.
K3<-future_map_dfr(seq(ncol(cluster_info)),function(Y){
K2<-map_dfr(seq(nrow(cluster_info)),function(index){
x <-cluster_info[,Y]
dist2 <- as.data.frame(cbind(x,dist))[-index,]
K1<-map_dfr(unique(x),function(i){
d<-mean(dist2[which(dist2$x==i),index+1])
#d<-sum(dist2[ which(dist2$x==i),index+1])/length( which(dist2$x==i))
data.frame(Value=d,clu=i)
})
si <- (min(K1[K1$clu!=x[index],]$Value)-K1[K1$clu==x[index],]$Value)/max(min(K1[K1$clu!=x[index],]$Value),K1[K1$clu==x[index],]$Value)
if(is.na(si)){
data.frame(cluster=x[index],sil_width=0)
}else{
data.frame(cluster=x[index],sil_width=si)
}
})
data.frame(Resolution=colnames(cluster_info)[Y],silhouette_score=mean(K2$sil_width))
})
from bigstatsr.
I don't get what you're trying to achieve here; sorry I cannot help.
from bigstatsr.
Related Issues (20)
- Predicting using only 1 specific lambda value HOT 2
- Fixed and random effect HOT 6
- Perform `colSums(X^2)` on FBM object HOT 2
- Variable selection HOT 6
- How to get p-value out of gwas<-big_univLinReg(...) object? HOT 10
- How to ensure indices of response are aligned with the genotype matrix in big_univLogReg? HOT 6
- Specify the location of the backing file resulting from `big_cor` HOT 8
- Binary traits problem HOT 1
- How to delete a .bk file during a session HOT 2
- Is there a function similar to rbind(), cbind() but for FBM objects HOT 2
- How to use big_apply properly HOT 4
- How to cbind/rbind two big matrices that have the same dimension HOT 9
- Issues with locking of the backing file HOT 6
- Implementation of `dimnames` for FBM matrices HOT 2
- Scaling predictor variables both in training and test datasets HOT 5
- Error in `big_cor()` when using `block.size = 1`
- Extracting scores from each inner validation HOT 2
- control MAF filtering? HOT 3
- big_prodMat throws takes a really long time and finally throws an out-of-memory error HOT 6
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 bigstatsr.