I am trying to run the code found on this page: https://github.com/lorinanthony/RATE
Specifically, I am trying to run Centrality_Tutorial.R in the Tutorials folder.
All of the code works up to the line where I actually call the RATE function (code below), and then I get Error in { : task 1 failed - "could not find function "sherman_r""
I have even run RATE.R with all of the same values generated by the code and there were no errors. The sherman_r function is loaded when the RATE.R is called (it is in the loaded values) and loads all functions there. I told my supervisor and he is able to make it work on his machine, and a colleague of his also got it to work.
I am working on a Windows 10 machine in RStudio. The latest version of R (4.1.0) is installed, all packages are up to date, and my machine is working. I have tried running on one core versus all 8 on my computer and still no luck.
I feel like I've tried everything, I've scoured the site for answers, please any suggestions are welcome.
Code being run, error occurs in last line:
library(corpcor)
library(doParallel)
library(MASS)
library(Matrix)
library(mvtnorm)
library(Rcpp)
library(RcppArmadillo)
library(RcppParallel)
### Load in the RATE R functions ### (Path set by user in both)
source("RATE.R")
### Load in the C++ BAKR functions ###
sourceCpp("BAKRGibbs.cpp")
set.seed(11151990)
n = 2e3; p = 25; pve=0.6; rho=1;
### Define the Number of Causal SNPs
ncausal = 3
### Simulate Synthetic Data ###
maf <- 0.05 + 0.45*runif(p)
X <- (runif(n*p) < maf) + (runif(n*p) < maf)
X <- matrix(as.double(X),n,p,byrow = TRUE)
Xmean=apply(X, 2, mean); Xsd=apply(X, 2, sd); X=t((t(X)-Xmean)/Xsd)
s=c(23:25)
#Marginal Effects Only
Xmarginal=X[,s]
beta1=rep(1,ncausal)
y_marginal=c(Xmarginal%*%beta1)
beta1=beta1*sqrt(pve*rho/var(y_marginal))
y_marginal=Xmarginal%*%beta1
#Pairwise Epistatic Effects
Xepi=cbind(X[,s[1]]*X[,s[3]],X[,s[2]]*X[,s[3]])
beta2=c(1,1)
y_epi=c(Xepi%*%beta2)
beta2=beta2*sqrt(pve*(1-rho)/var(y_epi))
y_epi=Xepi%*%beta2
#Error Terms
y_err=rnorm(n)
y_err=y_err*sqrt((1-pve)/var(y_err))
y=c(y_marginal+y_epi+y_err); #Full Model
colnames(X) = paste("SNP",1:ncol(X),sep="")
n = dim(X)[1] #Sample size
p = dim(X)[2] #Number of markers or genes
Kn = GaussKernel(t(X)); diag(Kn)=1 #
v=matrix(1, n, 1)
M=diag(n)-v%*%t(v)/n
Kn=M%*%Kn%*%M
Kn=Kn/mean(diag(Kn))
sigma2 = 1e-3
fhat = Kn %*% solve(Kn + diag(sigma2,n), y)
fhat.rep = rmvnorm(1e4,fhat,Kn - Kn %*% solve(Kn+diag(sigma2,n),Kn))
cores = detectCores()
registerDoParallel(cores=cores)
nl = NULL
res = RATE(X=X,f.draws=fhat.rep,snp.nms = colnames(X),cores = cores)
Edit: here is the traceback for the function error, in case this helps or sheds light on anything:
4.
stop(simpleError(msg, call = expr))
3.
e$fun(obj, substitute(ex), parent.frame(), e$data)
2.
foreach(j = int, .combine = "c") %dopar% {
q = unique(c(j, l))
m = abs(mu[q])
U_Lambda_sub = sherman_r(Lambda, V[, q], V[, q]) ... at RATE.R#75
1.
RATE(X = X, f.draws = fhat.rep, snp.nms = colnames(X), cores = cores)