generatescExpMa: Generate single cell expression matrix

View source: R/scAPAtrap_funlib.R

generatescExpMaR Documentation

Generate single cell expression matrix

Description

Given peaks' count and annotation file, this function can filter peaks with low expression levels and generate different types of objects, including data.frame (df), list with data.frame peaks.meta and Sparse Matrix peaks.count (list), SeuratObject (Seurat), SingleCellExperiment (sce), movAPA's PACdataset (PAC).

Usage

generatescExpMa(
  countsfile,
  peaksfile,
  barcode = NULL,
  tails = NULL,
  d = 100,
  min.cells = 10,
  min.count = 10,
  ofile = NULL,
  ...
)

Arguments

countsfile

The decompressed file path of counts.tsv.gz generated by countPeaks or a count table (gene/cell/count).

peaksfile

The path of the peaks.saf file generated by generateSAF.

barcode

Vector of the barcode list for filtering cells.

tails

The result produced by findTails or findTailsByPeaks. If provided, then filter tailed-peaks within d nt.

d

Max distance from the tail and peak to determine whether a peak is real (if it is within d-nt of a tail).

min.cells

peak is expressed in at least a few cells,the default value is 10.

min.count

peak minimum expression, the default value is 10.

ofile

if not NULL then output the an variable called scAPAtrapData to ofile, and return ofile.

...

Arguments passed to other methods and/or advanced arguments. Advanced arguments:

verbose

If 'TRUE' basic status updates will be printed along the way.

logf

If not NULL, then it should be a character string denoting a file name. Then message will be written to 'logf'.

Value

A list containing peaks.meta and peaks.count (ofile=NULL) or the ofile name (ofile!=NULL). The ofile is an RDA file which contains a variable called scAPAtrapData after load(ofile). The scAPAtrapData is a list.

Warning

The chromosome name in tails and peaksfile(peaks.saf) must be consistent (e.g., both be 1 or be Chr1).

Examples

## Not run: 
countsfile <- countPeaks(umitools.path,'./data/final.bam','./data',TenX=TRUE)
peakfile <- generateSAF(forwardPeaks,reversePeaks,'./data')
tails <- findTails(bamfile = './data/demo.bam')
barcode <- utils::read.delim2('./data/barcodes.tsv',header = FALSE)
barcode <- gsub('-[0-9]','',barcode$V1)
scExpMa <- generatescExpMa(countsfile, peaksfile, barcode, tails,
                          d=100, min.cells = 10, min.count = 10)
scExpMa2 <- eneratescExpMa(countsfile, peaksfile, barcode,
               min.cells = 10, min.count = 100,  verbose=TRUE, logf='xx.log')

## End(Not run)

BMILAB/scAPAtrap documentation built on Oct. 13, 2023, 2:36 a.m.