Entering edit mode
4.3 years ago
sadeghi.reyhane
•
0
Hi all I'm currently analyzing a microarray dataset using the WGCNA package. but am running into difficulty when relating the clinical traits to the eigenmodules.i have 3 group as patient and one group as control so in binary i used 0 for control and 1-3 for 3 patient group and it gave me this error:
-Error in labeledHeatmap(Matrix = moduleTraitCor, xLabels = names(datTraits), :
Length of 'xLabels' must equal the number of columns in 'Matrix.'
my codes are `# Define numbers of genes and samples
nGenes = ncol(datExpr);
nSamples = nrow(datExpr);
# Recalculate MEs with color labels
MEs0 = moduleEigengenes(datExpr, moduleColors)$eigengenes
MEs = orderMEs(MEs0)
moduleTraitCor = cor(MEs, datTraits, use = "p");
moduleTraitPvalue = corPvalueStudent(moduleTraitCor, nSamples);
sizeGrWindow(10,6)
# load data
data(agaricus.train, package='xgboost')
data(agaricus.test, package='xgboost')
train <- agaricus.train
test <- agaricus.test
# fit model
bst <- xgboost(data = train$data, label = train$label, max.depth = 2, eta = 1, nrounds = 2,
nthread = 2, objective = "binary:logistic")
# predict
pred <- predict(bst, test$data)
vec_y <- mtcars$vs
mat_y <- as.matrix(mtcars$vs)
df_y <- mtcars[,8,drop=FALSE] #column vs is the 8th column
x <- as.matrix(mtcars[,-8]) #column vs is the 8th column
#vector labels: works
xgboost::xgb.DMatrix(data=x, label=vec_y)
#matrix labels: works
xgboost::xgb.DMatrix(data=x, label=mat_y)
#df labels: doesnt work
xgboost::xgb.DMatrix(data=x, label=df_y)
# Will display correlations and their p-values
textMatrix = paste(signif(moduleTraitCor, 2), "\n(",
signif(moduleTraitPvalue, 1), ")", sep = "");
dim(textMatrix) = dim(moduleTraitCor)
par(mar = c(1, 15, 3, 3));
colnames(moduleTraitCor)=levels(as.factor(datTraits["ClinicalTraits"]))
# Display the correlation values within a heatmap plot
labeledHeatmap(Matrix = moduleTraitCor,
xLabels = names(datTraits),
yLabels = names(MEs),
ySymbols = names(MEs),
colorLabels = FALSE,
colors = greenWhiteRed(50),
textMatrix = textMatrix,
setStdMargins = FALSE,
cex.text = 0.5,
zlim = c(-1,1),
main = paste("Module-trait relationships"))`
Hi. What is the output of:
?
Well, there is the disparity. The error reads:
Your
xLabels
is:Your
Matrix
is:There is an apparent lack of sync between these. You should trace back through your code to understand why.
I've used this code for about 30 GSEs but only this time i stocked with this error i will check it again thank you so much
In that case, compare the output from
str()
between a GSE that works and the GSE to which you are referring in this thread. This would be a good debugging exercise.This is where your problem originated:
Your colnames() for moduleTraitCor should be the colnames() for datTraits you are interested in. You have mentioned in the beginning that you have 4 levels of condition or group. I would expect therefore to have 4 different columns for each variable, considering you are looking for "level vs all" or even "level1 vs level2" etc. effects. However, Looking at your
str(datTraits)
, you only have rows representing moduleEigenLabels and not columns, which should be the names or colnames of your datTraits (COntrol, Treatment1, Treatment2, Treatment3). Getting this corrected, you would have Length of 'xLabels' i.e. colnames of datTraits equal to the number of columns in Matrix of moduleTraitCor.thanks it was so useful but i'm amateur in R and i don't know how i can define column for datTraits
Could you show the output for
levels(as.factor(datTraits["ClinicalTraits"]))
? Also, if you can, please show your datTraits file, If your datTraits file is either a matrix or a dataframe and that "ClinicalTraits" is the name of one of the columns you are interested in, you should use following before runninglabeledHeatmap
function.Probably you forgot putting
,
to properly subset your column in datTraits file.can i have your mail?
I too have the same issue. Were you able to resolve this issue? I checked the datTraits files, dimnames(datTraits) was returned as NULL
Thanks