After mapping data to segments, this function can be used to remove segments that are too short, or that have too few mapped RNA genes or ATAC peaks. A parameters allows to input a list of segments that will be retained no matter what.

The function requires and returns an (R)CONGAS+ object.

filter_segments(
  x,
  length = 0,
  RNA_genes = 50,
  ATAC_peaks = 50,
  segments = list(),
  RNA_nonzerocells = 0,
  ATAC_nonzerocells = 0
)

Arguments

x

An rcongasplus object.

length

Mimium size in number of bases for each segment. This is 0 by default, and therefore non effective.

RNA_genes

Required number of RNA genes, if RNA is available. This is 50 by default.

ATAC_peaks

Required number of ATAC peaks, if ATAC is available. This is 50 by default.

segments

A list of segment ids to retain regardless of the filters.

Value

The object x where segments have been identified and removed.

Examples

data('example_object')

# Default
print(example_object)
#> ── [ (R)CONGAS+ ] SU008 TUMOR 30 segments (73.66% genome) ──────────────────────
#> 
#> ── CNA segments (reference: GRCh38) 
#> → Input 30 CNA segments, mean ploidy 3.2.
#> 
#> 	 | | |  | | | |  | | | |  | | |  | |  |   |  |  | 
#> 
#> 	 Ploidy:    0     1     2     3     4     5     *   
#> 
#> ── Modalities 
#> → RNA: 714 cells with 8613 mapped genes, 1401728 non-zero values. Likelihood: Negative Binomial.
#> → ATAC: 259 cells with 284316 mapped peaks, 3083691 non-zero values. Likelihood: Negative Binomial.
#> ! Clusters: not available.
#> 
#> ──  LOG  ──
#> 
#> - 2021-03-30 17:58:41 Created input object.
#> - 2021-03-30 17:58:43 Filtered outliers: [6|0.05|0.95]
#> [1] 0

example_object %>% 
  filter_segments() %>% 
  print()
#> ── Segments filter 
#>0 retained segments out of 30.
#> Error in filter_segments(.): All segments removed with these parameters.

# Minimum size
example_object %>% 
  filter_segments(length = 1e7) %>% 
  print()
#> 
#> ── Segments filter 
#>0 retained segments out of 30.
#> Error in filter_segments(., length = 1e+07): All segments removed with these parameters.