The MatchedGInteractions class is a subclass of both
Matched and GInteractions. Therefore, it contains slots
and methods for both of these classes.
The MatchedGInteractions class uses a delegate object
during initialization to assign its GInteractions slots.
MatchedGInteractions behaves as a GInteractions but also
includes additional Matched object functionality
(see ?Matched). For more information about
GInteractions see ?InteractionSet::GInteractions.
focalA GInteractions object containing the focal
data to match.
poolA GInteractions object containing the pool
from which to select matches.
delegateA GInteractions object used to initialize
GInteractions-specific slots. matchRanges() assigns
the matched set to the slot.
matchedDataA data.table with matched data
matchedIndexAn integer vector corresponding
to the indices in the pool which comprise the
matched set.
covarA character vector describing the covariates used for matching.
methodCharacter describing replacement method used for matching.
replaceTRUE/FALSE describing if matching was done with or without replacement.
anchor1anchorIds(delegate)$first
anchor2anchorIds(delegate)$second
regionsregions(delegate)
NAMESnames(delegate)
elementMetadataelementMetadata(delegate)
metadatametadata(delegate)
Functions that get data from Matched subclasses (x)
such as MatchedDataFrame, MatchedGRanges,
and MatchedGInteractions are listed below:
matchedData(x): Get matched data from a Matched object
covariates(x): Get covariates from a Matched object
method(x): Get matching method used for Matched object
withReplacement(x): Get replace method
indices(x, set): Get indices of matched set
For more detail check the help pages for these functions.
Additional functions that get data from Matched subclasses
(x) such as MatchedDataFrame, MatchedGRanges,
and MatchedGInteractions include:
focal(x): Get focal set from a Matched object
pool(x): Get pool set from a Matched object
matched(x): Get matched set from a Matched object
unmatched(x): Get unmatched set from a Matched object
For more detail check the help pages for these functions.
## Constructing MatchedGInteractions with matchRanges
set.seed(123)
gi <- makeExampleMatchedDataSet(type = "GInteractions")
mgi <- matchRanges(
focal = gi[gi$feature1, ],
pool = gi[!gi$feature1, ],
covar = ~ feature2 + feature3,
method = "rejection",
replace = FALSE
)
class(mgi)
#> [1] "MatchedGInteractions"
#> attr(,"package")
#> [1] "nullranges"
## Make MatchedGInteractions example
set.seed(123)
x <- makeExampleMatchedDataSet(type = "GInteractions", matched = TRUE)
## Accessor functions for Matched class
matchedData(x)
#> Index: <set>
#> id feature2 feature3 ps set
#> <fctr> <num> <char> <num> <char>
#> 1: 1 2.879049 c 0.21095908 focal
#> 2: 1 3.539645 c 0.19210984 focal
#> 3: 1 7.117417 c 0.11193396 focal
#> 4: 1 4.141017 a 0.01771986 focal
#> 5: 1 4.258575 c 0.17308581 focal
#> ---
#> 20496: 0 1.235781 b 0.08945367 unmatched
#> 20497: 0 1.696712 a 0.02707977 unmatched
#> 20498: 0 6.111404 a 0.01255772 unmatched
#> 20499: 0 2.216575 d 0.07578989 unmatched
#> 20500: 0 5.330029 b 0.04535856 unmatched
covariates(x)
#> [1] "feature2" "feature3"
method(x)
#> [1] "rejection"
withReplacement(x)
#> [1] FALSE
head(indices(x, set = 'matched'))
#> [1] 5975 5154 9730 3514 8940 6689
## Accessor functions for Matched subclasses
focal(x)
#> GInteractions object with 500 interactions and 3 metadata columns:
#> seqnames1 ranges1 seqnames2 ranges2 | feature1 feature2
#> <Rle> <IRanges> <Rle> <IRanges> | <logical> <numeric>
#> [1] chr1 1-100 --- chr1 1-100 | TRUE 2.87905
#> [2] chr1 2-101 --- chr1 2-101 | TRUE 3.53965
#> [3] chr1 3-102 --- chr1 3-102 | TRUE 7.11742
#> [4] chr1 4-103 --- chr1 4-103 | TRUE 4.14102
#> [5] chr1 5-104 --- chr1 5-104 | TRUE 4.25858
#> ... ... ... ... ... ... . ... ...
#> [496] chr1 496-595 --- chr1 496-595 | TRUE 1.28384
#> [497] chr1 497-596 --- chr1 497-596 | TRUE 4.36369
#> [498] chr1 498-597 --- chr1 498-597 | TRUE 4.32968
#> [499] chr1 499-598 --- chr1 499-598 | TRUE 4.72823
#> [500] chr1 500-599 --- chr1 500-599 | TRUE 5.10432
#> feature3
#> <character>
#> [1] c
#> [2] c
#> [3] c
#> [4] a
#> [5] c
#> ... ...
#> [496] d
#> [497] a
#> [498] b
#> [499] b
#> [500] b
#> -------
#> regions: 10500 ranges and 0 metadata columns
#> seqinfo: 1 sequence from an unspecified genome; no seqlengths
pool(x)
#> GInteractions object with 10000 interactions and 3 metadata columns:
#> seqnames1 ranges1 seqnames2 ranges2 | feature1 feature2
#> <Rle> <IRanges> <Rle> <IRanges> | <logical> <numeric>
#> [1] chr1 501-600 --- chr1 501-600 | FALSE 3.28347
#> [2] chr1 502-601 --- chr1 502-601 | FALSE 7.12640
#> [3] chr1 503-602 --- chr1 503-602 | FALSE 1.92222
#> [4] chr1 504-603 --- chr1 504-603 | FALSE 10.24116
#> [5] chr1 505-604 --- chr1 505-604 | FALSE 10.17287
#> ... ... ... ... ... ... . ... ...
#> [9996] chr1 10496-10595 --- chr1 10496-10595 | FALSE 1.23578
#> [9997] chr1 10497-10596 --- chr1 10497-10596 | FALSE 1.69671
#> [9998] chr1 10498-10597 --- chr1 10498-10597 | FALSE 6.11140
#> [9999] chr1 10499-10598 --- chr1 10499-10598 | FALSE 2.21657
#> [10000] chr1 10500-10599 --- chr1 10500-10599 | FALSE 5.33003
#> feature3
#> <character>
#> [1] e
#> [2] a
#> [3] b
#> [4] a
#> [5] c
#> ... ...
#> [9996] b
#> [9997] a
#> [9998] a
#> [9999] d
#> [10000] b
#> -------
#> regions: 10500 ranges and 0 metadata columns
#> seqinfo: 1 sequence from an unspecified genome; no seqlengths
matched(x)
#> GInteractions object with 500 interactions and 3 metadata columns:
#> seqnames1 ranges1 seqnames2 ranges2 | feature1 feature2
#> <Rle> <IRanges> <Rle> <IRanges> | <logical> <numeric>
#> [1] chr1 6475-6574 --- chr1 6475-6574 | FALSE 5.27263
#> [2] chr1 5654-5753 --- chr1 5654-5753 | FALSE 10.02427
#> [3] chr1 10230-10329 --- chr1 10230-10329 | FALSE 8.19732
#> [4] chr1 4014-4113 --- chr1 4014-4113 | FALSE 7.83727
#> [5] chr1 9440-9539 --- chr1 9440-9539 | FALSE 4.69472
#> ... ... ... ... ... ... . ... ...
#> [496] chr1 1767-1866 --- chr1 1767-1866 | FALSE 1.95550
#> [497] chr1 6099-6198 --- chr1 6099-6198 | FALSE 4.98042
#> [498] chr1 3743-3842 --- chr1 3743-3842 | FALSE 2.62560
#> [499] chr1 4425-4524 --- chr1 4425-4524 | FALSE 1.40300
#> [500] chr1 8468-8567 --- chr1 8468-8567 | FALSE 3.89279
#> feature3
#> <character>
#> [1] c
#> [2] c
#> [3] a
#> [4] c
#> [5] c
#> ... ...
#> [496] a
#> [497] c
#> [498] e
#> [499] c
#> [500] b
#> -------
#> regions: 10500 ranges and 0 metadata columns
#> seqinfo: 1 sequence from an unspecified genome; no seqlengths
unmatched(x)
#> GInteractions object with 9500 interactions and 3 metadata columns:
#> seqnames1 ranges1 seqnames2 ranges2 | feature1 feature2
#> <Rle> <IRanges> <Rle> <IRanges> | <logical> <numeric>
#> [1] chr1 501-600 --- chr1 501-600 | FALSE 3.28347
#> [2] chr1 502-601 --- chr1 502-601 | FALSE 7.12640
#> [3] chr1 503-602 --- chr1 503-602 | FALSE 1.92222
#> [4] chr1 504-603 --- chr1 504-603 | FALSE 10.24116
#> [5] chr1 505-604 --- chr1 505-604 | FALSE 10.17287
#> ... ... ... ... ... ... . ... ...
#> [9496] chr1 10496-10595 --- chr1 10496-10595 | FALSE 1.23578
#> [9497] chr1 10497-10596 --- chr1 10497-10596 | FALSE 1.69671
#> [9498] chr1 10498-10597 --- chr1 10498-10597 | FALSE 6.11140
#> [9499] chr1 10499-10598 --- chr1 10499-10598 | FALSE 2.21657
#> [9500] chr1 10500-10599 --- chr1 10500-10599 | FALSE 5.33003
#> feature3
#> <character>
#> [1] e
#> [2] a
#> [3] b
#> [4] a
#> [5] c
#> ... ...
#> [9496] b
#> [9497] a
#> [9498] a
#> [9499] d
#> [9500] b
#> -------
#> regions: 10500 ranges and 0 metadata columns
#> seqinfo: 1 sequence from an unspecified genome; no seqlengths