(Re)-intergrated VDJ and GEX of one or two separate VGM objects. This can be used as a simple "updating" utility function, if metadata has been added to the VDJ dataframe and is also needed in the GEX matrix or the reverse. Entries are integrated by barcode. If barcodes have been altered (barcode column in VDJ and cell names in GEX), the function will not yield results

VGM_integrate(VGM, columns.to.transfer, genes.to.VDJ, seurat.slot)

Arguments

VGM

Output object from the VDJ_GEX_matrix function (VDJ_GEX_matrix.output)

columns.to.transfer

Optional. Character Vector. Column names of either the VDJ matrix or GEX meta.data that should be transferred to the corresponding other matrix. if not provided all columns missing from one will be integrated into the other matrix

genes.to.VDJ

Character vector of gene names in GEX. In many cases it is useful to extract expression values for a gene to metadata. This is done via SeuratObject::FetchData(vars = genes,slot = seurat.slot) function. The VGM integrate takes gene ids, extracts these and adds them to the VDJ dataframe. If provided, no other columns are integrated between VDJ and GEX and columns.to.transfer is ignored.

seurat.slot

GEX object data slot to pull from. Can be 'counts', 'data', or 'scale.data'

Value

An output object from the VDJ_GEX_matrix function with added columns in VDJ or GEX

Examples


#Adding a new clonotyping method to VDJ
small_vgm[[1]] <- VDJ_clonotype(VDJ=Platypus::small_vgm[[1]],
clone.strategy="cdr3.nt",
hierarchical = "single.chains", global.clonotype = TRUE)
#> Clonotyping strategy: cdr3.nt
#> Hierarchical clonotyping is specifically designed to incorporate cells with abberand numbers of chains. Filtering for 1VDJ 1VJ chain thereby defeats its purpose. Function will continue without filtering.
#> Filtered out 1 cells containing more than one VDJ AND VJ chain or two VDJ chains, as these likely correspond to doublets
#> Processing sample 1 of 1
#> Attempting to merge in 17 aberrant cells
#> Backing up 10x default clonotyping in columns clonotype_id_10x and clonotype_frequency_10x before updating clonotype_id and clonotype_frequency columns

small_vgm <- VGM_integrate(
VGM = small_vgm,
columns.to.transfer = NULL) #transfer all new columns
#> Cells in GEX: 21; cells in VDJ: 49
#>  Overlap: 20 
#> Integrating all VDJ columns which are not in GEX to GEX
#> Added columns to GEX: clonotype_id; global_clonotype_frequency_cdr3.nt; global_clonotype_id_cdr3.nt; global_clonal_feature_cdr3.nt; clonotype_frequency_10x; clonotype_id; clonotype_frequency
#and update clonotype_id and clonotype_frequency column
#(as does VDJ_clonotype_v3 in VDJ)

small_vgm <- VGM_integrate(
VGM = small_vgm,
columns.to.transfer = c("global_clonotype_id_cdr3.nt"))
#> Cells in GEX: 21; cells in VDJ: 49
#>  Overlap: 20 
#transfer only selected columns

#Pull genes from GEX and add as metadata column to VDJ

small_vgm <- VGM_integrate(
small_vgm, genes.to.VDJ = c("CD19","CD24A"),seurat.slot = "counts")
#> Cells in GEX: 21; cells in VDJ: 49
#>  Overlap: 20 
#> Added columns to VDJ: CD19; CD24A