May be useful when plotting Manhattan or Q-Q plots for GWAS results to speed up plotting.
Arguments
- df
A data frame.
- pval_col
Name of column in
df
containing p values.- sig
Significance threshold. P values equal to or greater than this will be sampled.
- n, prop
Provide either
n
, the number of rows, orprop
, the proportion of rows to select. If neither are supplied,n = 1
will be used.If a negative value of
n
orprop
is provided, the specified number or proportion of rows will be removed.If
n
is greater than the number of rows in the group (orprop > 1
), the result will be silently truncated to the group size. If theprop
ortion of a group size does not yield an integer number of rows, the absolute value ofprop*nrow(.data)
is rounded down.
Examples
dummy_manhattan_df() %>%
sample_nonsig_results(pval_col = "P",
sig = 0.001,
n = 2)
#> # A tibble: 6 × 5
#> CHR SNP BETA SE P
#> <chr> <chr> <dbl> <dbl> <dbl>
#> 1 1 b 0 0.02 0.0001
#> 2 1 c -0.1 0.03 0.000000001
#> 3 11 l -0.1 0.03 0.0001
#> 4 11 o -0.1 0.03 0.0001
#> 5 2 d 0.1 0.01 0.01
#> 6 3 h 0 0.02 0.05