Last active
May 31, 2023 11:47
-
-
Save CnrLwlss/a5d434246eb260eb1d903f8b5d56c60c to your computer and use it in GitHub Desktop.
Simulating protein pixel intensities in fibre sections with freezing artefacts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# A possible problem with freezing artefacts and correlations | |
# Need MASS library to sample from multivariate normal distribution (correlated datasets) | |
library(MASS) | |
R_good = matrix(c(0.55, 0.5, | |
0.5, 0.55), | |
nrow = 2, ncol = 2, byrow = TRUE) | |
R_bad = matrix(c(1, 0.5, | |
0.5, 1), | |
nrow = 2, ncol = 2, byrow = TRUE) | |
R_hole = matrix(c(0.1, 0.05, | |
0.05, 0.1), | |
nrow = 2, ncol = 2, byrow = TRUE) | |
# Simulate fibre where proteins are well correlated | |
dat_good = MASS::mvrnorm(1000, mu = c(X = 10, Y = 10), Sigma = R_good) | |
# Simulate fibre where proteins are poorly correlated | |
dat_bad = MASS::mvrnorm(1000, mu = c(X = 10, Y = 10), Sigma = R_bad) | |
# Simulate poor correlation between proteins within the "missing" pixels of a fibre with a hole caused by freezing artefact | |
dat_hole = MASS::mvrnorm(1000, mu = c(X = 2, Y = 2), Sigma = R_hole) | |
# Simulate a fibre with a mixture of some normal pixels (where protein correlation is poor) | |
# and some pixels with freezing artefacts | |
dat_mix = rbind(dat_bad[1:500,],dat_hole[1:500,]) | |
op = par(mfrow=c(2,2)) | |
plot(dat_good[,1],dat_good[,2],xlab="log(VDAC1)",ylab="log(NDUFB8)",main=paste("Good correlation:",formatC(cor(dat_good[,1],dat_good[,2]),3)),xlim=c(0,15),ylim=c(0,15),pch=16,col=rgb(0,0,0,0.1)) | |
plot(dat_bad[,1],dat_bad[,2],xlab="log(VDAC1)",ylab="log(NDUFB8)",main=paste("Bad correlation:",formatC(cor(dat_bad[,1],dat_bad[,2]),3)),xlim=c(0,15),ylim=c(0,15),pch=16,col=rgb(0,0,0,0.1)) | |
plot(dat_hole[,1],dat_hole[,2],xlab="log(VDAC1)",ylab="log(NDUFB8)",main=paste("Hole correlation:",formatC(cor(dat_hole[,1],dat_hole[,2]),3)),xlim=c(0,15),ylim=c(0,15),pch=16,col=rgb(0,0,0,0.1)) | |
plot(dat_mix[,1],dat_mix[,2],xlab="log(VDAC1)",ylab="log(NDUFB8)",main=paste("Mix correlation:",formatC(cor(dat_mix[,1],dat_mix[,2]),3)),xlim=c(0,15),ylim=c(0,15),pch=16,col=rgb(0,0,0,0.1)) | |
par(op) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment