# \donttest{
#### Subset normalization
# datasets
npx_df1 <- npx_data1 |>
dplyr::filter(!stringr::str_detect(SampleID, "CONTROL_")) |>
dplyr::select(-Project) |>
dplyr::mutate(Normalization = "Intensity")
npx_df2 <- npx_data2 |>
dplyr::filter(!stringr::str_detect(SampleID, "CONTROL_")) |>
dplyr::select(-Project) |>
dplyr::mutate(Normalization = "Intensity")
# Find a suitable subset of samples from both projects, but exclude Olink
# controls and samples that fail QC.
df1_samples <- npx_df1 |>
dplyr::filter(!stringr::str_detect(SampleID, "CONTROL_")) |>
dplyr::group_by(SampleID) |>
dplyr::filter(all(QC_Warning == 'Pass')) |>
dplyr::pull(SampleID) |>
unique() |>
sample(size = 16, replace = FALSE)
df2_samples <- npx_df2 |>
dplyr::filter(!stringr::str_detect(SampleID, "CONTROL_")) |>
dplyr::group_by(SampleID) |>
dplyr::filter(all(QC_Warning == 'Pass')) |>
dplyr::pull(SampleID) |>
unique() |>
sample(size = 16, replace = FALSE)
# create named list
subset_samples_list <- list("DF1" = df1_samples,
"DF2" = df2_samples)
# Normalize
olink_normalization_subset(project_1_df = npx_df1,
project_2_df = npx_df2,
reference_samples = subset_samples_list,
project_1_name = "P1",
project_2_name = "P2",
project_ref_name = "P1")
#### Special case of subset normalization using all samples
# datasets
npx_df1 <- npx_data1 |>
dplyr::filter(!stringr::str_detect(SampleID, "CONTROL_")) |>
dplyr::select(-Project) |>
dplyr::mutate(Normalization = "Intensity")
npx_df2 <- npx_data2 |>
dplyr::filter(!stringr::str_detect(SampleID, "CONTROL_")) |>
dplyr::select(-Project) |>
dplyr::mutate(Normalization = "Intensity")
# Find a suitable subset of samples from both projects, but exclude Olink
# controls and samples that fail QC.
df1_samples_all <- npx_df1 |>
dplyr::filter(!stringr::str_detect(SampleID, "CONTROL_")) |>
dplyr::group_by(SampleID) |>
dplyr::filter(all(QC_Warning == 'Pass')) |>
dplyr::pull(SampleID) |>
unique()
df2_samples_all <- npx_df2 |>
dplyr::filter(!stringr::str_detect(SampleID, "CONTROL_")) |>
dplyr::group_by(SampleID) |>
dplyr::filter(all(QC_Warning == 'Pass')) |>
dplyr::pull(SampleID) |>
unique()
# create named list
subset_samples_all_list <- list("DF1" = df1_samples_all,
"DF2" = df2_samples_all)
# Normalize
olink_normalization_subset(project_1_df = npx_df1,
project_2_df = npx_df2,
reference_samples = subset_samples_all_list,
project_1_name = "P1",
project_2_name = "P2",
project_ref_name = "P1")
# }
Run the code above in your browser using DataLab