I have a slightly infuriating problem.
I want to run polygenic to correct for relatedness on a trait with no covariates. Ordinarily, I'd run it like this:
Code: Select all
a <- polygenic(eGFR, data=data,kin=kin)
That works fine. However, I have a lot of these to run and I don't want to hard-code everything, so I've got a script that gets the trait to run as a string.
Code: Select all
traitName <- "eGFR"
Ideally I want to use the value of the traitName variable as the formula.
Code: Select all
> a <- polygenic(traitName, data=data,kin=kin)
Error in polygenic(traitName, data = df2, kin = gkin) :
dimension of outcome and kinship.matrix do not match
as.formula doesn't help me here as that needs a right hand side
Code: Select all
> as.formula(traitName)
Error in eval(expr, envir, enclos) : object 'eGFR_overall' not found
And using ~1 as a RHS doesn't work in polygenic:
Code: Select all
form <- as.formula(paste0(traitName, "~1"))
> a <- polygenic(form,data=df2,kin=gkin)
Error in polygenic(form, data = df2, kin = gkin) :
All covariates have only one value
I'm at my wits' end here. Does anyone know how to get around this?
Thanks
