msc.sample.correlation {caMassClass} | R Documentation |
Calculates correlations between different samples and correlations between different copies of the same sample
msc.sample.correlation(X, PeaksOnly=FALSE)
X |
Spectrum data either in matrix format [nFeatures x nSamples] or in
3D array format [nFeatures x nSamples x nCopies]. Row names
(rownames(X)) store M/Z mass of each row. |
PeaksOnly |
Should only peaks be used in calculating the correlation? In case of raw mass spectra data it does not make much sense to calculate correlation of "valleys" between peaks so one can set this flag to TRUE and only points above sample mean will be used. |
Function calculates for each copy of each sample two variables:
innerCor[iSamp,iCopy]
measures average
correlation between X[,iSamp,iCopy]
and all other copies of that
sample. In case of one copy of the data innerCor
is set to one. In
case of two
copies innerCor[iSamp,1]
= innerCor[iSamp,2]
=
cor(X[,iSamp,1],X[,iSamp,2])
.
In case of 3 copies innerCor[iSamp,1]
=
(cor(X[,iSamp,1],X[,iSamp,2])
+
cor(X[,iSamp,1],X[,iSamp,3]))/2
,etc.
Returns list with two components: innerCor
and outerCor
both of size [nSamples x nCopies].
Jarek Tuszynski (SAIC) jaroslaw.w.tuszynski@saic.com
msc.preprocess.run
and
msc.project.run
pipelines.
msc.copies.merge
function.
cor
function
# load input data if (!file.exists("Data_IMAC.Rdata")) example("msc.project.read") load("Data_IMAC.Rdata") # run in 3D input data using long syntax out = msc.mass.adjust.calc (X); Y = msc.mass.adjust.apply(X, out$ShiftX, out$ScaleY, out$ShiftY) # check what happen to sample correlation A = msc.sample.correlation(X, PeaksOnly=TRUE) B = msc.sample.correlation(Y, PeaksOnly=TRUE) cat("Mean corelation between two copies of the same sample:\n") cat(" before: ", ai<-mean(A$innerCor)," after: ", bi<-mean(B$innerCor), "\n") cat("Mean corelation between unrelated samples:\n") cat(" before: ", ao<-mean(A$outerCor)," after: ", bo<-mean(B$outerCor), "\n") stopifnot(ao<bo, ai<bi, bo<bi, abs(bi-0.91)<0.01, abs(ao-0.75)<0.01)