I have a list text file of IDs:
JJ-58390234
JJ-45983252
JJ-90590485025825
JJ-0123343
etc... roughly 20,000 long
I have a table called genomics:
ID gene sex age height diagnosis pc1 pc2 pc3
JJ-1234 CFTR M 43 123 ihd 0.1 0.54 0.543
etc.... roughly 100,000 lines long
These are stored using labkey (https://www.labkey.com/) and we use a mysql script to query the tables via R.
I would like to pull out the diagnosis and pc1, pc2 and pc3 for a select number of IDs.
I know how to do this for a specific "thing" in the table e.g. for the diagnosis
lab.setDefaults(baseURL = "#code for labkey")
query <- "SELECT g.diagnosis, g.pc1, pc2, g.pc3
FROM genomic as g
WHERE g.diagnosis = 'ihd'"
mysql <- labkey.executeSql(
schemaName="lists",
colNameOpt = "rname",
maxROWS = 100000000,
folderPath="/main-programme_v10",
sql= query)
However, I don't know how to subset the table by the IDs in the text file. I don't think the labkey API allows for the creation of temporary tables which I understand would have made things easier. Is there a method to loop over each ID and run a separate query?
Many thanks