Skip to main content

2. Encode the outcome

You could dive right in and fit a regression model. E.g. if you focus on the O blood group variant rs8176719:

# Useful function to give us a nice result
broom::tidy(
# This is the actual regression
glm( status ~ rs8176719, family = "binomial", data = abo_data )
)

But you'll probably find this fails with a message about the yy values.

Of course! For logistic regression, the YY values should be 00 or 11, whereas in our data they are strings.

To fix this let's encode YY as a number instead. We'll map cases to 11 and controls to 00. A simple way is to convert status to a factor:

There are lots of ways to do this but here's a fairly readable one:

abo_data = (
abo_data
%>% mutate(
status = factor( status, levels = c( "CONTROL", "CASE" ))
)
)

(Another way to do this is to replace status with a new variable equal to 00 or 11.)

You should now be able to run the above regression and get some results.