View source: R/assign_missingness.R
assign_missingness | R Documentation |
The type of missingness (missing at random, missing not at random) is assigned based on the comparison of a reference condition and every other condition.
assign_missingness(
data,
sample,
condition,
grouping,
intensity,
ref_condition = "all",
completeness_MAR = 0.7,
completeness_MNAR = 0.2,
retain_columns = NULL
)
data |
a data frame containing at least the input variables. |
sample |
a character column in the |
condition |
a character or numeric column in the |
grouping |
a character column in the |
intensity |
a numeric column in the |
ref_condition |
a character vector providing the condition that is used as a reference for
missingness determination. Instead of providing one reference condition, "all" can be supplied,
which will create all pairwise condition pairs. By default |
completeness_MAR |
a numeric value that specifies the minimal degree of data completeness to be considered as MAR. Value has to be between 0 and 1, default is 0.7. It is multiplied with the number of replicates and then adjusted downward. The resulting number is the minimal number of observations for each condition to be considered as MAR. This number is always at least 1. |
completeness_MNAR |
a numeric value that specifies the maximal degree of data completeness to be considered as MNAR. Value has to be between 0 and 1, default is 0.20. It is multiplied with the number of replicates and then adjusted downward. The resulting number is the maximal number of observations for one condition to be considered as MNAR when the other condition is complete. |
retain_columns |
a vector that indicates columns that should be retained from the input
data frame. Default is not retaining additional columns |
A data frame that contains the reference condition paired with each treatment condition.
The comparison
column contains the comparison name for the specific treatment/reference
pair. The missingness
column reports the type of missingness.
"complete": No missing values for every replicate of this reference/treatment pair for the specific grouping variable.
"MNAR": Missing not at random. All replicates of either the reference or treatment condition have missing values for the specific grouping variable.
"MAR": Missing at random. At least n-1 replicates have missing values for the reference/treatment pair for the specific grouping varible.
NA: The comparison is not complete enough to fall into any other category. It will not
be imputed if imputation is performed. For statistical significance testing these comparisons
are filtered out after the test and prior to p-value adjustment. This can be prevented by setting
filter_NA_missingness = FALSE
in the calculate_diff_abundance()
function.
The type of missingness has an influence on the way values are imputeted if imputation is
performed subsequently using the impute()
function. How each type of missingness is
specifically imputed can be found in the function description. The type of missingness
assigned to a comparison does not have any influence on the statistical test in the
calculate_diff_abundance()
function.
set.seed(123) # Makes example reproducible
# Create example data
data <- create_synthetic_data(
n_proteins = 10,
frac_change = 0.5,
n_replicates = 4,
n_conditions = 2,
method = "effect_random",
additional_metadata = FALSE
)
head(data, n = 24)
# Assign missingness information
data_missing <- assign_missingness(
data,
sample = sample,
condition = condition,
grouping = peptide,
intensity = peptide_intensity_missing,
ref_condition = "all",
retain_columns = c(protein)
)
head(data_missing, n = 24)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.