Function to obtain Discrete Local Maxima based estimates of pvalues for z-scores maximized over subsets (of traits or subtypes), with possible restrictions and weights. Should not be called directly. See details.

1 2 |

`t.vec` |
Numeric vector of (positive) points for which to calculate p-values, i.e. general observed Z-max values. No default. |

`k` |
Integer (currently less than 30). The number of studies (traits) or subtypes being analyzed. No default. |

`search` |
0, 1 or 2. Search option, with 0 indicating subtype analysis, 1 and 2 denote one-sided and two-sided subset-search. No default. |

`side` |
Either 1 or 2. For two-tailed tests (where absolute values of Z-scores are maximized), side should be 2. For one-tailed tests side should be 1 (positive tail assumed). No default. Ignored when search is 2. |

`cor.def` |
A function with at least 3 arguments which calculates correlation between its first argument (a subset) and its second argument (subsets such as its neighbors). The third argument is the number of traits/subtypes and the function should return a vector of correlations with the neighbors. If NULL or a non-function value is specified, internal default functions for the corresponding search option are used. |

`cor.args` |
Other arguments to be passed to |

`sizes` |
Sizes of equivalence classes of traits. By default, no two traits or studies are equivalent. This argument is for internal use. |

`sub.def` |
A function to restrict subsets, e.g., order restrictions in subtype analysis. Should accept a subset (a logical vector of size k) as its first argument and should return TRUE if the subset satisfies restrictions and FALSE otherwise. Default is NULL implying all (2^k - 1) subsets are considered in the maximum. |

`sub.args` |
Other arguments to be passed to |

`wt.def` |
A function that gives weight of one subset with respect to another. Should accept two subsets as first two argumets and return a single positive weight. Default NULL. Currently this option is not implemented and the argument is ignored. |

`wt.args` |
Other arguments to be passed to |

The function is vectorized to handle blocks of SNPs at a time. Currently weight options are ignored.
This is a helper function that is called internally by `h.traits`

and `h.types`

and should not be called directly. The arguments of this function that have defaults, can be customized using
the argument `pval.args`

in `h.traits`

and `h.types`

.

A numeric vector of estimated p-values.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | ```
set.seed(123)
# A function to define the correlations between a subset and its neighbors
# Returned values should not exceed the value of 1
cor.def <- function(subset, neighbors, k, ncase, ncntl) {
n <- ncol(neighbors)
mat <- matrix(subset, nrow=k, ncol=n, byrow=FALSE)
cor <- (mat + neighbors)*(1:k)/(k^2)
cor <- colSums(cor)
cor <- cor/max(cor)
dim(cor) <- c(n, 1)
cor
}
# Subset definition
sub.def <- function(logicalVec) {
# Only allow the cummulative subsets:
# TRUE FALSE FALSE FALSE ...
# TRUE TRUE FALSE FALSE ...
# TRUE TRUE TRUE FALSE ...
# etc
sum <- sum(logicalVec)
ret <- all(logicalVec[1:sum])
ret
}
k <- 5
t.vec <- 3 + runif(k)
p.dlm(t.vec, k, 1, 2, cor.def=cor.def, sub.def=sub.def,
cor.args=list(ncase=rep(1000, k), ncntl=rep(1000,k)))
``` |

Questions? Problems? Suggestions? Tweet to @rdrrHQ or email at ian@mutexlabs.com.

Please suggest features or report bugs with the GitHub issue tracker.

All documentation is copyright its authors; we didn't write any of that.