The same variant affect two traits
noisy.data <- list()
noisy.data2 <- list()
X <- N3finemapping$X[,1:100]
for ( i in 1:nrow(X))
{
f1_obs <- f1
f2_obs <- f2
noise1 <- rnorm(length(f1), sd= (1/ rsnr ) * var(f1))
noise2 <- rnorm(length(f1), sd= (1/ rsnr ) * var(f2))
noisy.data [[i]] <- X[i,pos1]*f1_obs + noise1
noisy.data2 [[i]] <- X[i,pos2]*f2_obs + noise2
}
noisy.data <- do.call(rbind, noisy.data)
noisy.data2 <- do.call(rbind, noisy.data2)
Y1 <- noisy.data
Y2 <- noisy.data
Fine mapping each trait separetly
out1 <- susiF(Y1,X,L=10 )
#> [1] "Starting initialization"
#> [1] "Data transform"
#> [1] "Discarding 0 wavelet coefficients out of 128"
#> [1] "Data transform done"
#> [1] "Initializing prior"
#> [1] "Initialization done"
#> [1] "Fitting effect 1 , iter 1"
#> [1] "Fitting effect 2 , iter 1"
#> [1] "Fitting effect 3 , iter 1"
#> [1] "Discarding 2 effects"
#> [1] "Fine mapping done, refining effect estimates using cylce spinning wavelet transform"
out2 <- susiF(Y2,X,L=10 )
#> [1] "Starting initialization"
#> [1] "Data transform"
#> [1] "Discarding 0 wavelet coefficients out of 128"
#> [1] "Data transform done"
#> [1] "Initializing prior"
#> [1] "Initialization done"
#> [1] "Fitting effect 1 , iter 1"
#> [1] "Fitting effect 2 , iter 1"
#> [1] "Fitting effect 3 , iter 1"
#> [1] "Discarding 2 effects"
#> [1] "Fine mapping done, refining effect estimates using cylce spinning wavelet transform"
Make sure that bf1 and bf2 have SNP in common, in this exemple we simply add the name a posterior. However, coloc requires that bf1 and bf2 have some names in common
library(coloc)
#> This is coloc version 5.2.3
bf1 <- exp(out1$lBF[[1]])
names(bf1) <- paste("SNP", rep(1:100))
bf2 <- exp(out2$lBF[[1]])
names(bf2) <- paste("SNP", rep(1:100))
coloc.bf_bf(bf1=bf1, bf2=bf2)
#> $summary
#> nsnps hit1 hit2 PP.H0.abf PP.H1.abf PP.H2.abf PP.H3.abf PP.H4.abf idx1
#> <int> <char> <char> <num> <num> <num> <num> <num> <int>
#> 1: 100 SNP 25 SNP 25 0 0 0 0 1 1
#> idx2
#> <int>
#> 1: 1
#>
#> $results
#> snp SNP.PP.H4.abf
#> <char> <num>
#> 1: SNP 1 0
#> 2: SNP 2 0
#> 3: SNP 3 0
#> 4: SNP 4 0
#> 5: SNP 5 0
#> 6: SNP 6 0
#> 7: SNP 7 0
#> 8: SNP 8 0
#> 9: SNP 9 0
#> 10: SNP 10 0
#> 11: SNP 11 0
#> 12: SNP 12 0
#> 13: SNP 13 0
#> 14: SNP 14 0
#> 15: SNP 15 0
#> 16: SNP 16 0
#> 17: SNP 17 0
#> 18: SNP 18 0
#> 19: SNP 19 0
#> 20: SNP 20 0
#> 21: SNP 21 0
#> 22: SNP 22 0
#> 23: SNP 23 0
#> 24: SNP 24 0
#> 25: SNP 25 1
#> 26: SNP 26 0
#> 27: SNP 27 0
#> 28: SNP 28 0
#> 29: SNP 29 0
#> 30: SNP 30 0
#> 31: SNP 31 0
#> 32: SNP 32 0
#> 33: SNP 33 0
#> 34: SNP 34 0
#> 35: SNP 35 0
#> 36: SNP 36 0
#> 37: SNP 37 0
#> 38: SNP 38 0
#> 39: SNP 39 0
#> 40: SNP 40 0
#> 41: SNP 41 0
#> 42: SNP 42 0
#> 43: SNP 43 0
#> 44: SNP 44 0
#> 45: SNP 45 0
#> 46: SNP 46 0
#> 47: SNP 47 0
#> 48: SNP 48 0
#> 49: SNP 49 0
#> 50: SNP 50 0
#> 51: SNP 51 0
#> 52: SNP 52 0
#> 53: SNP 53 0
#> 54: SNP 54 0
#> 55: SNP 55 0
#> 56: SNP 56 0
#> 57: SNP 57 0
#> 58: SNP 58 0
#> 59: SNP 59 0
#> 60: SNP 60 0
#> 61: SNP 61 0
#> 62: SNP 62 0
#> 63: SNP 63 0
#> 64: SNP 64 0
#> 65: SNP 65 0
#> 66: SNP 66 0
#> 67: SNP 67 0
#> 68: SNP 68 0
#> 69: SNP 69 0
#> 70: SNP 70 0
#> 71: SNP 71 0
#> 72: SNP 72 0
#> 73: SNP 73 0
#> 74: SNP 74 0
#> 75: SNP 75 0
#> 76: SNP 76 0
#> 77: SNP 77 0
#> 78: SNP 78 0
#> 79: SNP 79 0
#> 80: SNP 80 0
#> 81: SNP 81 0
#> 82: SNP 82 0
#> 83: SNP 83 0
#> 84: SNP 84 0
#> 85: SNP 85 0
#> 86: SNP 86 0
#> 87: SNP 87 0
#> 88: SNP 88 0
#> 89: SNP 89 0
#> 90: SNP 90 0
#> 91: SNP 91 0
#> 92: SNP 92 0
#> 93: SNP 93 0
#> 94: SNP 94 0
#> 95: SNP 95 0
#> 96: SNP 96 0
#> 97: SNP 97 0
#> 98: SNP 98 0
#> 99: SNP 99 0
#> 100: SNP 100 0
#> snp SNP.PP.H4.abf
#>
#> $priors
#> p1 p2 p12
#> 1e-04 1e-04 5e-06