Running polygenic with no covariates, passing a string as the formula

Questions about GenABEL (aka *ABEL) suite of packages
Forum rules
Please remember not to post any sensitive data on this public forum.
The first few posts of newly registered users will be moderated in order to filter out any spammers.

When get a solution to the problem you posted, please change the topic name (e.g. from "how to ..." to "[SOLVED] how to ..."). This will make it easier for the community to follow the posts yet to be attended.
jmarten
Posts: 4
Joined: Thu Dec 19, 2013 12:51 pm

Running polygenic with no covariates, passing a string as the formula

Postby jmarten » Thu Oct 20, 2016 11:22 am

Hello all,

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 :)

Return to “GenABEL”

Who is online

Users browsing this forum: Bing [Bot] and 1 guest