rbind_score_list: Combine multiple exSTRa data objects.

View source: R/rbind_score_list.R

rbind_score_listR Documentation

Combine multiple exSTRa data objects.

Description

Allows data from multiple exstra_score objects to be combined, similarly to rbindlist (data.table) and rbind. The exstra_score objects may either be given directly to rbind_score, or as a list to rbind_score_list that is easier to use when the number of objects to combine is not known in advance.

Usage

rbind_score_list(
  strscore_list,
  idcol = "data_group",
  allow_sample_clash = FALSE,
  fill = FALSE
)

rbind_score(
  ...,
  idcol = "data_group",
  allow_sample_clash = FALSE,
  fill = FALSE
)

Arguments

strscore_list

A list containing exstra_score objects.

idcol

The name of the column giving the names of strscore_list in the output.

allow_sample_clash

If TRUE, allows a sample name to occur multiple times in the exstra_score objects, otherwise duplicates cause an error.

fill

If TRUE, missing columns are filled with NAs. Default FALSE.

...

exstra_score objects to combine.

Value

An exstra_score object.

See Also

rbindlist, rbind

Examples

# create a list of distinct samples
score_list <- list(group1 = exstra_wgs_pcr_2[, "WGSrpt_20"], 
                   controls = exstra_wgs_pcr_2[, c("WGSrpt_02", "WGSrpt_04")],
                   group2 = exstra_wgs_pcr_2[, c("WGSrpt_15", "WGSrpt_16")]
                  )
combined_scores <- rbind_score_list(score_list)
combined_scores$samples

# Without using a list:
rbind_score(group1 = exstra_wgs_pcr_2[, "WGSrpt_20"], 
            controls = exstra_wgs_pcr_2[, c("WGSrpt_02", "WGSrpt_04")],
            group2 = exstra_wgs_pcr_2[, c("WGSrpt_15", "WGSrpt_16")]
            )$samples

# Combining with a repeated sample name, possibly due to multiple experiments.
# Splitting data for this example:
score_1 <- exstra_wgs_pcr_2["DM1", "WGSrpt_15"]
score_2 <- exstra_wgs_pcr_2["HD", "WGSrpt_15"]
# Combine with the sample name repeated across exstra_score objects:
rbind_score_list(list(score_1, score_2), allow_sample_clash = TRUE)
# or
rbind_score(score_1, score_2, allow_sample_clash = TRUE)

bahlolab/exSTRa documentation built on Sept. 17, 2022, 5:08 p.m.