Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ export(getPgenPtr)
export(getPhenotypeCovariates)
export(getPhenotypes)
export(getPip)
export(getQcDiagnostics)
export(getQcInfo)
export(getQtlDatasets)
export(getRefPanel)
Expand Down Expand Up @@ -232,6 +233,7 @@ export(screenCtwasRegions)
export(sdpr)
export(sdprWeights)
export(slalom)
export(sldscPostprocessingPipeline)
export(sliceMashData)
export(standardiseSumstatsColumns)
export(standardizeSldscTrait)
Expand Down Expand Up @@ -309,6 +311,7 @@ exportMethods(getPgenPtr)
exportMethods(getPhenotypeCovariates)
exportMethods(getPhenotypes)
exportMethods(getPip)
exportMethods(getQcDiagnostics)
exportMethods(getQcInfo)
exportMethods(getQtlDatasets)
exportMethods(getRefPanel)
Expand Down
22 changes: 22 additions & 0 deletions R/AllClasses.R
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,28 @@ setMethod("getGenome", "SumStatsBase", function(x, ...) x@genome)
#' @export
setMethod("getQcInfo", "SumStatsBase", function(x, ...) x@qcInfo)

#' @rdname getQcDiagnostics
#' @export
setMethod("getQcDiagnostics", "SumStatsBase",
function(x, entry = 1L, ...) {
qc <- x@qcInfo
if (length(qc) == 0L) return(NULL)
audits <- qc$entryAudit
if (is.null(audits)) return(NULL)
if (is.null(entry)) {
out <- lapply(audits, function(a) a$ldMismatchDiagnostics)
keep <- !vapply(out, is.null, logical(1L))
if (!any(keep)) return(NULL)
setNames(out[keep], seq_along(audits)[keep])
} else {
if (!is.numeric(entry) || length(entry) != 1L ||
entry < 1L || entry > length(audits)) {
stop("`entry` must be a single integer in 1:", length(audits), ".")
}
audits[[as.integer(entry)]]$ldMismatchDiagnostics
}
})

#' @rdname getLdSketch
#' @export
setMethod("getLdSketch", "SumStatsBase", function(x, ...) x@ldSketch)
Expand Down
20 changes: 20 additions & 0 deletions R/AllGenerics.R
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,26 @@ setGeneric("getGenome", function(x, ...) standardGeneric("getGenome"))
#' @export
setGeneric("getQcInfo", function(x, ...) standardGeneric("getQcInfo"))

#' @title Get SLALOM / DENTIST Diagnostics
#' @description Return the per-variant LD-mismatch diagnostics table
#' (SLALOM or DENTIST output) attached to a sumstats entry by
#' \code{\link{summaryStatsQc}} when \code{zMismatchQc} was not
#' \code{"none"}. Convenience accessor over
#' \code{getQcInfo(x)$entryAudit[[entry]]$ldMismatchDiagnostics}.
#' @param x A \code{GwasSumStats} or \code{QtlSumStats} object.
#' @param entry Integer index (default 1) of the entry whose diagnostics
#' table to return. When \code{NULL}, returns a named list of every
#' entry's diagnostics keyed by entry index.
#' @param ... Unused.
#' @return A \code{data.frame} of per-variant diagnostics (columns
#' include \code{variant_id} plus the SLALOM / DENTIST output
#' columns), \code{NULL} when no diagnostics were preserved for that
#' entry, or a named list of such data.frames when \code{entry =
#' NULL}.
#' @export
setGeneric("getQcDiagnostics",
function(x, entry = 1L, ...) standardGeneric("getQcDiagnostics"))

#' @title Get LD Sketch
#' @description Return the \code{GenotypeHandle} carrying the LD
#' reference for this collection. Defined on classes that embed an
Expand Down
Loading
Loading