Skip to contents

Set motif matrix for given assay

Usage

SetMotifData(object, ...)

# S3 method for class 'Motif'
SetMotifData(object, slot, new.data, ...)

# S3 method for class 'ChromatinAssay5'
SetMotifData(object, slot, new.data, ...)

# S3 method for class 'Seurat'
SetMotifData(object, assay = NULL, ...)

Arguments

object

A Seurat object

...

Arguments passed to other methods

slot

Name of slot to use

new.data

motif matrix to add. Should be matrix or sparse matrix class

assay

Name of assay whose data should be set

Value

Returns a SeuratObject::Seurat() object

Examples

motif.obj <- SeuratObject::GetAssayData(
  object = atac_small[["peaks"]], slot = "motifs"
)
SetMotifData(object = motif.obj, slot = "data", new.data = matrix(1:2))
#> A Motif object containing 1 motifs in 2 regions
new.data <- matrix(sample(c(0, 1),
  size = nrow(atac_small[["peaks"]]) * 10,
  replace = TRUE
), nrow = nrow(atac_small[["peaks"]]))
rownames(new.data) <- rownames(atac_small[["peaks"]])
SetMotifData(
  object = atac_small[["peaks"]], slot = "data", new.data = new.data
)
#> Warning: Overwriting motif information
#> GRangesAssay data with 100 features for 100 cells
#> Variable features: 0 
#> Annotation present: TRUE 
#> Fragment files: 0 
#> Motifs present: TRUE 
#> Links present: 0 
#> Region aggregation matrices: 0
motif.matrix <- GetMotifData(object = atac_small)
SetMotifData(
  object = atac_small,
  assay = "peaks",
  slot = "data",
  new.data = motif.matrix
)
#> Warning: Overwriting motif information
#> An object of class Seurat 
#> 150 features across 100 samples within 2 assays 
#> Active assay: peaks (100 features, 0 variable features)
#>  2 layers present: counts, data
#>  1 other assay present: RNA
#>  2 dimensional reductions calculated: lsi, umap