signac icon indicating copy to clipboard operation
signac copied to clipboard

Export bigwig files from split fragments file

Open Baboon61 opened this issue 1 year ago • 11 comments

This pull request is answering this enhancement : https://github.com/stuart-lab/signac/issues/28 Most of the code is coming from ArchR, I rewrote it for a Signac object.

Addition of ExportGroupBW, CreateBWGroup and %bcin% to Utilities.R, to export bigwig file from a split fragments file

library(Signac)
library(GenomicRanges)
library(future)
library(future.apply)
library(rtracklayer)
library(Matrix)

Splitting the fragments file for each group as :

SplitFragments(
  object = pbmc,
  assay = "peaks",
  group.by = "seurat_clusters",
  idents = c(0,2),
  outdir = getwd(),
  file.suffix = "",
  append = TRUE,
  buffer_length = 256L,
  verbose = TRUE
)

Exporting the fragments file for each group as :

exportGroupBW(
  object = pbmc, #The seurat object
  assay = "peaks", #The assay of the fragment file
  group.by = "seurat_clusters", #The metadata used to split the fragment file
  idents = c(0,2), #The idents from the group.by to be exported
  normMethod = "ncells" #Normalization method for the biwig files. It can be the name of any quantitative column in the @meta.data or ncells as the number of cells. Can also be set to none
  tileSize = 100, #The size of the tiles in the bigwig file
  minCells = 5, #The minimum of cells in a group to be exported
  cutoff = 4, #The maximum number of fragment in a given tile
  chromosome = "primary", The chromosomes to be exported. Primary or all
  threads = 4, Number of threads
  outdir = getwd(), #The output directory for bigwig files. Also used as output directory for SlitFragment function
  verbose=TRUE #Display messages
)

Baboon61 avatar Apr 19 '23 09:04 Baboon61