varSetList.Rd
An S4 class to manage varSets. varSets can be generated from annotations using
the buildVarSet()
method. Specific units and/or annotations can be retrieved using
the getVarSet
method. A varSetList can be used directly as input in assocTest()
to perform
burden/single variant association tests on the varSets included in the varSetList.
The on-disk equivalent of a varSetList
is varSetFile()
, from which varSets can be retrieved
in the same way as a varset list using the getVarSet
method.
buildVarSet(x, ...)
: Generate a varSetList or varSetFile()
that stores weighted variant sets
for use in association testing. This can be based on 1) annotations uploaded to the gdb or 2) a data.frame including annotations.
See buildVarSet()
for details.
In the following code snippets, x is a varSetList object.
getVarSet(x, unit, varSetName)
: Retrieve varSets for specified units and/or varSetNames.
listUnits(x)
: Return a vector of all units included in the varSetList.
listVarSets(x)
: Return a vector of all varSetNames included in the varSetList.
getGdbId(x)
: Get gdb ID from metadata
metadata(x)
: Get metadata from varSetList
A varSetList can be subsetted in the same way as a normal R list,
however, getVarSet
is the most convenient way to select varSets (see above).
Some examples, where x is a varSetList object:
x[[i]]
: Return the i'th varSet
x[i:j]
: Return the i'th till j'th varSets
A varSetList can be directly supplied to the assocTest()
gdb method, using the
varSet
parameter. Association tests will then be performed for each varSet included
in the varSetList.
In the following code snippets, x is a varSetList object:
collapseVarSetList(x, unit = "unnamed", varSetName = "unnamed)
:
Merge all varSets into one varSet. All weights will be set to 1.
Optionally, the unit name and varSetName can be specified.
This method is mainly used when you want to load the genotypes for all variants
in a varSetList using getGT()
.
write(x, file = "data", append = "FALSE")
: Write the varSetList to disk, in
the varSetFile
format.
library(rvatData)
# connect to varsetfile from rvatData package
# to build a varsetfile, see ?buildVarSet
varsetfile <- varSetFile(rvat_example("rvatData_varsetfile.txt.gz"))
# extract a couple of genes from the varSetFile, which whill return a varSetList
varsetlist <- getVarSet(varsetfile, c("SOD1", "FUS"))
varsetlist
#> varSetList
#> Contains 8 records
#> [[1]]
#> unit=FUS
#> varSetName=Moderate
#> VAR_id=1176,1177,1180,1182,1183,1186,1188,1192,1193,1194,1196,1198,1200,1202,1205,1206,1207,1208,1210,1211,1215,1216,1218,1219,1221,1222,1223,1224,1225,1226,1227,1228,1233,1234,1236,1239,1240,1241,1244,1245,1246,1248,1249,1250,1252,1253,1254,1256,1257,1258,1261,1262,1263,1265,1266
#> w=1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
#>
#> [[2]]
#> unit=FUS
#> varSetName=ModerateHigh
#> VAR_id=1175,1176,1177,1180,1182,1183,1186,1188,1192,1193,1194,1196,1198,1200,1202,1205,1206,1207,1208,1210,1211,1215,1216,1218,1219,1221,1222,1223,1224,1225,1226,1227,1228,1233,1234,1236,1239,1240,1241,1244,1245,1246,1248,1249,1250,1252,1253,1254,1256,1257,1258,1261,1262,1263,1265,1266
#> w=1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
#>
#> [[3]]
#> unit=FUS
#> varSetName=High
#> VAR_id=1175
#> w=1
#>
#> [[4]]
#> unit=FUS
#> varSetName=CADD
#> VAR_id=1173,1174,1175,1176,1177,1178,1179,1180,1181,1182,1183,1184,1185,1186,1187,1188,1189,1190,1191,1192,1193,1194,1195,1196,1197,1198,1199,1200,1201,1202,1203,1204,1205,1206,1207,1208,1209,1210,1211,1212,1213,1214,1215,1216,1217,1218,1219,1220,1221,1222,1223,1224,1225,1226,1227,1228,1229,1230,1231,1232,1233,1234,1235,1236,1237,1238,1239,1240,1241,1242,1243,1244,1245,1246,1247,1248,1249,1250,1251,1252,1253,1254,1255,1256,1257,1258,1259,1260,1261,1262,1263,1264,1265,1266,1267
#> w=.,.,.,26.5,22.4,.,.,32,.,24.7,24.5,.,.,.,.,13.68,.,.,.,22.1,13.66,15.72,.,26.4,.,26,.,22.7,.,19.21,.,.,17.9,.,23.3,24,.,0.058,1.247,.,.,.,7.445,17.84,.,16.16,24.8,.,21.6,23.2,25.8,24.1,31,32,26.9,23.2,.,.,.,.,31,20.3,.,23.7,.,.,19.45,24.6,23.3,.,.,26,.,22.9,.,17.24,28.8,31,.,25,19.89,23.1,.,.,24.6,23.4,.,.,22,25.3,24.4,.,26.5,23.7,.
#>
#> [[5]]
#> unit=SOD1
#> varSetName=Moderate
#> VAR_id=1268,1270,1271,1273,1275,1276,1277,1278,1279,1281,1282,1283,1284,1285,1287,1288,1289,1290,1291,1292,1293,1294,1296,1297,1298,1299,1300,1304,1305,1306,1307,1308,1309,1312,1313,1314,1315,1316
#> w=1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
#>
#> [[6]]
#> unit=SOD1
#> varSetName=ModerateHigh
#> VAR_id=1268,1270,1271,1273,1275,1276,1277,1278,1279,1281,1282,1283,1284,1285,1286,1287,1288,1289,1290,1291,1292,1293,1294,1296,1297,1298,1299,1300,1301,1302,1304,1305,1306,1307,1308,1309,1311,1312,1313,1314,1315,1316
#> w=1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
#>
# many of the varSetFile methods are also available for a varSetList
# for example, getVarSet can also be used to extract specific genes or varSets from a varSetList
getVarSet(varsetlist, unit = "SOD1")
#> varSetList
#> Contains 4 records
#> [[1]]
#> unit=SOD1
#> varSetName=Moderate
#> VAR_id=1268,1270,1271,1273,1275,1276,1277,1278,1279,1281,1282,1283,1284,1285,1287,1288,1289,1290,1291,1292,1293,1294,1296,1297,1298,1299,1300,1304,1305,1306,1307,1308,1309,1312,1313,1314,1315,1316
#> w=1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
#>
#> [[2]]
#> unit=SOD1
#> varSetName=ModerateHigh
#> VAR_id=1268,1270,1271,1273,1275,1276,1277,1278,1279,1281,1282,1283,1284,1285,1286,1287,1288,1289,1290,1291,1292,1293,1294,1296,1297,1298,1299,1300,1301,1302,1304,1305,1306,1307,1308,1309,1311,1312,1313,1314,1315,1316
#> w=1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
#>
#> [[3]]
#> unit=SOD1
#> varSetName=High
#> VAR_id=1286,1301,1302,1311
#> w=1,1,1,1
#>
#> [[4]]
#> unit=SOD1
#> varSetName=CADD
#> VAR_id=1268,1269,1270,1271,1272,1273,1274,1275,1276,1277,1278,1279,1280,1281,1282,1283,1284,1285,1286,1287,1288,1289,1290,1291,1292,1293,1294,1295,1296,1297,1298,1299,1300,1301,1302,1303,1304,1305,1306,1307,1308,1309,1310,1311,1312,1313,1314,1315,1316
#> w=31,.,23.4,.,.,13.44,.,23.9,24.9,22.7,24.9,24.5,.,29.6,26.5,27.1,31,26.2,34,26.6,32,29,14.85,26.2,25,16.46,23.2,.,24.3,17.52,22.8,27.4,27.6,.,25.1,.,.,23.4,28.2,27.9,16.67,27.4,.,42,25.7,.,29.2,22.4,27.3
#>
# list included units and varSets
units <- listUnits(varsetlist)
head(units)
#> [1] "FUS" "FUS" "FUS" "FUS" "SOD1" "SOD1"
varsets <- listVarSets(varsetlist)
head(varsets)
#> [1] "Moderate" "ModerateHigh" "High" "CADD" "Moderate"
#> [6] "ModerateHigh"
# several basic list operations work on a varSetList
length(varsetlist)
#> [1] 8
varsetlist[1:2]
#> varSetList
#> Contains 2 records
#> [[1]]
#> unit=FUS
#> varSetName=Moderate
#> VAR_id=1176,1177,1180,1182,1183,1186,1188,1192,1193,1194,1196,1198,1200,1202,1205,1206,1207,1208,1210,1211,1215,1216,1218,1219,1221,1222,1223,1224,1225,1226,1227,1228,1233,1234,1236,1239,1240,1241,1244,1245,1246,1248,1249,1250,1252,1253,1254,1256,1257,1258,1261,1262,1263,1265,1266
#> w=1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
#>
#> [[2]]
#> unit=FUS
#> varSetName=ModerateHigh
#> VAR_id=1175,1176,1177,1180,1182,1183,1186,1188,1192,1193,1194,1196,1198,1200,1202,1205,1206,1207,1208,1210,1211,1215,1216,1218,1219,1221,1222,1223,1224,1225,1226,1227,1228,1233,1234,1236,1239,1240,1241,1244,1245,1246,1248,1249,1250,1252,1253,1254,1256,1257,1258,1261,1262,1263,1265,1266
#> w=1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
#>
varsetlist[[1]]
#> unit=FUS
#> varSetName=Moderate
#> VAR_id=1176,1177,1180,1182,1183,1186,1188,1192,1193,1194,1196,1198,1200,1202,1205,1206,1207,1208,1210,1211,1215,1216,1218,1219,1221,1222,1223,1224,1225,1226,1227,1228,1233,1234,1236,1239,1240,1241,1244,1245,1246,1248,1249,1250,1252,1253,1254,1256,1257,1258,1261,1262,1263,1265,1266
#> w=1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
# extract metadata
metadata(varsetlist)
#> $rvatVersion
#> [1] "0.3.1"
#>
#> $gdbId
#> [1] "vmo8w57mh9lhjhijqf5ja9fu0suj"
#>
#> $genomeBuild
#> [1] "GRCh38"
#>
#> $creationDate
#> [1] "2024-11-20 11:42:04"
#>
getRvatVersion(varsetlist)
#> [1] "0.3.1"
getGdbId(varsetlist)
#> [1] "vmo8w57mh9lhjhijqf5ja9fu0suj"
# all varsets in in a varsetlist can be collapsed into one varSet using the
# collapseVarSetList method
collapseVarSetList(varsetlist)
#> unit=unnamed
#> varSetName=unnamed
#> VAR_id=1176,1177,1180,1182,1183,1186,1188,1192,1193,1194,1196,1198,1200,1202,1205,1206,1207,1208,1210,1211,1215,1216,1218,1219,1221,1222,1223,1224,1225,1226,1227,1228,1233,1234,1236,1239,1240,1241,1244,1245,1246,1248,1249,1250,1252,1253,1254,1256,1257,1258,1261,1262,1263,1265,1266,1175,1173,1174,1178,1179,1181,1184,1185,1187,1189,1190,1191,1195,1197,1199,1201,1203,1204,1209,1212,1213,1214,1217,1220,1229,1230,1231,1232,1235,1237,1238,1242,1243,1247,1251,1255,1259,1260,1264,1267,1268,1270,1271,1273,1275,1276,1277,1278,1279,1281,1282,1283,1284,1285,1287,1288,1289,1290,1291,1292,1293,1294,1296,1297,1298,1299,1300,1304,1305,1306,1307,1308,1309,1312,1313,1314,1315,1316,1286,1301,1302,1311,1269,1272,1274,1280,1295,1303,1310
#> w=1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
# varSetLists can be written to a varSetFile on disk using the write method
output <- tempfile()
write(varsetlist, output)
varsetfile <- varSetFile(output)
varsetfile
#> varSetFile object
#> Path:/var/folders/cl/wvc0rvjx4vd5rzt2_fhpmfth0000gp/T//RtmpRC6myU/file1825c7edb50fd
#> Units:8
# see e.g., ?assocTest and ?aggregate for downstream methods that can loop through varSets included in a varSetlist