summarize_by_patient: Simplify binary matrix to one column per patient that counts...

View source: R/summarize-by-patient.R

summarize_by_patientR Documentation

Simplify binary matrix to one column per patient that counts any alteration type across all samples as 1

Description

This will reduce the number of columns in your binary matrix, and the resulting data frame will have only 1 col per gene, as opposed to separate columns for mutation/cna/fusion.

Usage

summarize_by_patient(gene_binary, other_vars = NULL)

Arguments

gene_binary

a 0/1 matrix of gene alterations

other_vars

One or more column names (quoted or unquoted) in data to be retained in resulting data frame. Default is NULL.

Details

Note that if samples to the same patient were sequenced on different panels, any indication of an alteration is counted as an alteration, but the absence of an alteration is only defined when all sequencing panels included the gene and indicated that it was not altered.

Value

a binary matrix with a row for each sample and one column per gene

Examples

samples <- unique(gnomeR::mutations$sampleId)[1:10]
gene_binary <- create_gene_binary(
  samples = samples, mutation = mutations, cna = cna,
  mut_type = "somatic_only",
  include_silent = FALSE,
  specify_panel = "IMPACT341")

gene_binary$patient_id = extract_patient_id(gene_binary$sample_id)

summarize_by_patient(gene_binary)


AxelitoMartin/gnomeR documentation built on Oct. 18, 2024, 11:39 a.m.