Wed Jun 26 15:30:48 2013
The long term goal is to discover structure that is meaningful in terms of treatment outcomes.
C-data (time_series_cc200_20130402): C is for connectome, which just refers, in this case, to the fMRI data. The 197 regions are obtained from the 'all voxel' data via parsing voxels into regions. We already know the function relating the 197 to the all voxels case, because we wrote it. It is in the form of \( (region=197)\times (time=194)\times (subj=42) \). Unfortunately, the time-series across subjects are not aligned relative to one another.
P-data (NEO2012.csv): P is short for phenotype, in this case, it is the 5 factor model (\( (subj=42)\times (factor=5) \)), which are the 5 factors: ENOAC (sometimes ordered differently and called OCEAN).
NEO2012.csv has 42 subjects and the following columns: ParticipantID,Sex,Age,E,N,O,A,C the last 5 are the “5 factors”
NEO2012_linkage.csv has 42 subjects and 2 columns: the first is the ParticipantID, which is listed in the other file, the second is the file name. so it maps participant id to file, which we need.
ScaledScales.xls: this is the file that had the original data that i extracted NEO2012.csv from. you shouldn't need it, but it is the raw data, so i didn't want to discard it.
dname <- "http://www.cis.jhu.edu/~parky/CGP/Data/time_series_cc200_20130402/"
urlfiles <- readHTMLTable(dname, skip.rows = 1:2)[[1]]$V2
urlfiles <- urlfiles[!is.na(urlfiles)]
files <- paste0(dname, urlfiles)
(n <- length(files)) # 42
require(flexmix)
coh <- ts <- spect <- spect_norm <- NULL
for (i in 1:length(files)) {
ts[[i]] <- readMat(files[i])[[1]] # 194 x 197
spect[[i]] <- spectrum(t(ts[[i]]))$spec[6:40, ] # 100 (freq) x 194 => (bandpass) 35 x 194
spect_norm[[i]] <- scale(spect[[i]], center = FALSE, scale = colSums(spect[[i]])) # normalization
coh[[i]] <- KLdiv(spect_norm[[i]]) # Delta: 194 x 194
}
dissmat <- matrix(0, n, n)
for (i in 1:(n - 1)) {
for (j in (i + 1):n) {
dissmat[i, j] <- helldist(coh[[i]], coh[[j]]) # hellinger distance
}
}
dissmat <- dissmat + t(dissmat)
diag(dissmat) <- 0
distC <- normalize(dissmat)
# [1] 42 42
n <- nrow(distC)
mdsC <- cmdscale(distC, n - 1)
elbowC <- getElbows(mdsC, 3)
mcC <- Mclust(mdsC[, 1:elbowC[2]])
plot(mcC, "BIC")
require(gdata)
fname <- "http://www.cis.jhu.edu/~parky/CGP/Data/NEO2012.csv"
neo <- read.csv(fname)
pdat <- neo[, 4:8]
distP <- as.matrix(dist(pdat))
plotmat(as.matrix(pdat), "subject", "factor")
distP <- normalize(distP)
dim(distP)
plotmat(distP, "subject", "subject")
hist(distP)
mdsP <- cmdscale(distP, n - 1)
elbowP <- getElbows(mdsP, 3)
mcP <- Mclust(mdsP[, 1:elbowP[3]])
plot(mcP, "BIC")
# distC <- distP set.seed(123) distC <- jitter(distP,17000)
# plotmat(distC,main='distC = jitter(distP,100)')
# plotmat(distP,main='distP')
# plotmat(abs(distC-distP),main='abs(distC-distP)')
## form omnibus matrix
meanD <- (distC + distP)/2
omni <- rbind(cbind(distC, meanD), cbind(t(meanD), distP))
dim(omni)
# [1] 84 84
## embed
n2 <- n * 2
# mds <- cmdscale(omni,n2-1)
w <- 0.01
W1 <- matrix(w, n, n)
W2 <- matrix(0, n, n)
diag(W2) <- 1 - w
W <- rbind(cbind(W1, W2), cbind(t(W2), W1))
mds <- smacofSym(omni, n2 - 1, weightmat = W)$conf
elbow <- getElbows(mds, 3)
knee <- elbow[1]
dat <- mds[, 1:knee]
mcJ <- Mclust(dat)
plot(mcJ, "BIC")
plot(dat, col = mcJ$class, pch = as.numeric(lab), main = "Symbol: data, Color: cluster")
adjustedRandIndex(mcJ$class[1:n], mcJ$class[(n + 1):n2])
# [1] 1
adjustedRandIndex(mcJ$class[1:n], Sex)
# [1] -0.002763
mcJ2 <- Mclust(dat[1:n, ])
plot(mcJ2, "BIC")
mcJ2 <- Mclust(dat[1:n, ], 2)
plot(dat[1:n, ], col = mcJ2$class, pch = Sex + 1, main = "Symbol: Sex, Color: cluster")
adjustedRandIndex(mcJ2$class[1:n], Sex)
# [1] -0.02215