Deleted:External trait matching in WGCNA - converting categorical variables?
0
0
Entering edit mode
Nathalie • 0
@865d968f
Last seen 20 months ago
Germany

Hello! I am doing a WGCNA and during the process of external trait matching I stumbled upon the problem, that in order to correlate the eigengenes I need numeric values. The problem is that I have categorical variables. Am I allowed to just convert them to numeric values, or does this mess up the statistic?


    traitData <- read.table("sampleinfo_comb.txt", header = T)

    Samples <- rownames(datExpr0)

    nGenes = ncol(datExpr0)
    nSamples = nrow(datExpr0)


    #In Order to correlate traits to the eigengenes, we need numeric values (Am I allowed to do it like this, or do I need another correlation method??)

    traitData$Treatment <- as.numeric(factor(traitData$Treatment, levels = c("no_challenge", "challenge")))
    traitData$Setting <- as.numeric(factor(traitData$Setting, levels = c("group", "isolation"))) #converts group=1 and isolation=2
    traitData$Caste <- as.numeric(factor(traitData$Caste, levels = c("worker", "queen"))) # converts worker=1 and queen=2

    #########

    module.trait.correlation = cor(mergedMEs, traitData, use = "p") #p for pearson correlation coefficient 
    module.trait.Pvalue = corPvalueStudent(module.trait.correlation, nSamples)

This code generated some pretty results for my data, I am just not sure whether it is the appropiate method for my categorical traits?

Thanks for any advice!

RNASeqData WGCNA • 604 views
ADD COMMENT
This thread is not open. No new answers may be added
Traffic: 804 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6