andreyshabalin / MatrixEQTL

Matrix eQTL: Ultra fast eQTL analysis via large matrix operations
53 stars 16 forks source link

Categorical covariates with >2 groups? #13

Closed erbader closed 3 years ago

erbader commented 3 years ago

Hello!

We would like to use MatrixEQTL to test for the interaction between genotype and a categorical covariate with 4 groups. To do this, will we have to use multiple dummy variables, or is there an option to force Matrix EQTL to treat a covariate with >2 groups as categorical? Thank you! Elyssa

andreyshabalin commented 3 years ago

Dear @erbader,

I'm sorry, there is no built in support for categorical variables in Matrix eQTL.

Below is my typical response to an inquiry like yours:

Binary covariates are ok to encode with 0 and 1. Categorical covariates need to be split into dummy variables. Here is an example on how to do it:

x = as.factor(rep(1:6,each=4)); model.matrix(~x)[,-1]

Please note that Matrix eQTL always includes a constant in the model, thus I remove it [the first column] from the model.matrix output in the code above.

Andrey