Salmon quantifies how well each transcript abundance is determined by the
reads, and writes that information next to quant.sf:
read_inferential_replicates()reads the Gibbs (--numGibbsSamples) or bootstrap (--numBootstraps) replicates fromaux_info/bootstrap/(the format is identical in Salmon 1.x and in the Rust rewrite, Salmon 2). It returns a list with one transcript x sample matrix of counts per replicate, the layout used byproductive_fraction()andadd_uncertainty(). The samples are read one at a time, so memory holds the result and the replicates of a single sample. When the samples have different numbers of replicates, the smallest number is kept. The mean and variance over the kept replicates of every transcript, including those left out bytranscripts, are recorded in themomentsattribute:inferential_overdispersion()estimates its prior from them, so it does not depend on which transcripts are kept.equivalence_support()reads the equivalence classes (--dumpEq,aux_info/eq_classes.txt.gz) and reports, for every transcript, how many of its fragments are compatible with no other transcript.salmon_run_qc()readsaux_info/meta_info.jsonand reports the mapping rate, the library type, whether the optimiser converged and how many replicates were drawn.inferential_replicates_table()andas_inferential_replicates()convert the list of replicates to and from a long table (one row per transcript, sample and replicate), which can be stored as Parquet withwrite_parquet()and read back withread_parquet(), for example to exchange them with other tools.inferential_moments_table()converts themomentsattribute to a table in the same way (one row per transcript and sample); pass it to themomentsargument ofas_inferential_replicates()to restore it. The long table takes several times the memory of the replicates: to save the replicates of an object, usewrite_isoformic(), which writes one wide file per draw. Both apply theselectionof the replicates of a subsetx[i, j](see IsoformicExperiment): the replicate table holds the kept transcripts and samples only, the moment table the kept samples (the moments keep every transcript). The selection is an attribute of the unmodifiedx@metadata$inf_reps: a list operation such aslapply()or[drops it, and the list then holds the draws of the parent. Pass the object asx(alone, or with such a list asreps) to read the draws of its transcripts and samples in every case.
The functions also read Oarfish output (see read_oarfish()): its
bootstrap replicates (.infreps.pq), its unique and ambiguous read counts
(.ambig_info.tsv, n_classes is then NA) and its run metadata
(.meta_info.json). One call reads the output of one tool.
Usage
read_inferential_replicates(
paths,
transcripts = NULL,
n_draws = NULL,
ignore_after_bar = TRUE
)
equivalence_support(paths, transcripts = NULL, ignore_after_bar = TRUE)
salmon_run_qc(paths, min_percent_mapped = 50)
inferential_replicates_table(reps = NULL, x = NULL)
inferential_moments_table(reps = NULL, x = NULL)
as_inferential_replicates(table, samp_type = "gibbs", moments = NULL)Arguments
- paths
Character vector of Salmon output directories (containing
quant.sf) or paths toquant.sffiles, or Oarfish output prefixes. Names, when present, are the sample IDs; otherwise the directory name (or the prefix) is used.- transcripts
Optional transcript IDs to keep. Reading every transcript of a human annotation for many samples takes gigabytes of memory, so
add_uncertainty()only reads the expressed ones.- n_draws
Number of replicates to keep (the first ones).
NULLkeeps all of them; a number above the replicates available keeps all of them, with a message.- ignore_after_bar
Logical. Keep only the part of transcript names before the first
|(GENCODE FASTA headers used as Salmon references).- min_percent_mapped
Samples below this mapping rate (percent) get the
low_mapping_rateflag insalmon_run_qc().- reps
A list of transcript x sample count matrices, one per replicate. In
inferential_replicates_table()andinferential_moments_table(), it defaults tox@metadata$inf_repswhenxis given.- x
Optional IsoformicExperiment. When given, the replicates are read as those of its transcripts and samples, matched by ID, even when
repslost theselectionof a subset.- table
A long table with
transcript_id,sample_id,drawandcountcolumns, as returned byinferential_replicates_table().- samp_type
Replicate type recorded on the result,
"gibbs"or"bootstrap".- moments
Optional table of
inferential_moments_table()(columnstranscript_id,sample_id,n_draws,meanandvar) to record as themomentsattribute of the result.
Value
read_inferential_replicates(): a list of numeric matrices (transcripts by samples, counts) with the replicate type ("gibbs"or"bootstrap") in thesamp_typeattribute and the moments of every transcript in themomentsattribute (a list with themeanandvarmatrices, transcripts by samples, and the number of replicatesn).inferential_replicates_table(): a tibble withtranscript_id,sample_id,drawandcount.as_inferential_replicates()is its inverse.inferential_moments_table(): a tibble withtranscript_id,sample_id,n_draws,meanandvar.equivalence_support(): a tibble with one row per transcript:transcript_id,n_classes(mean number of equivalence classes that contain the transcript, per sample),n_fragmentsandn_unique_fragments(summed over samples),unique_fraction(share of the fragments of the transcript that map to it alone) andn_samples(samples with equivalence classes).salmon_run_qc(): a tibble with one row per sample:sample_id,salmon_version,library_type,detected_library_type,num_processed,num_mapped,percent_mapped,replicate_type,num_replicates,optimiser,em_converged,seq_bias_correct,gc_bias_correct,pos_bias_correct,frag_length_mean,frag_length_sdandqc_flag(low_mapping_rate,no_replicatesandem_not_converged, separated by;, orNA). For Oarfish output the columns aresample_id,num_processed,num_mapped,percent_mapped,replicate_type,num_replicates,optimiser,alignment_source,prob_modelandqc_flag, and thetoolattribute is"oarfish".
Examples
quant_dirs <- list.files(
system.file("extdata", "mini_quants", package = "isoformic"),
full.names = TRUE
)
names(quant_dirs) <- sub("_quant$", "", basename(quant_dirs))
# The bundled quantifications were made without replicates
salmon_run_qc(quant_dirs)[, c("sample_id", "percent_mapped", "qc_flag")]
#> # A tibble: 6 × 3
#> sample_id percent_mapped qc_flag
#> <chr> <dbl> <chr>
#> 1 SRR11498039 0.324 low_mapping_rate
#> 2 SRR11498040 0.422 low_mapping_rate
#> 3 SRR11498041 0.486 low_mapping_rate
#> 4 SRR11498077 0.449 low_mapping_rate
#> 5 SRR11498078 0.551 low_mapping_rate
#> 6 SRR11498079 0.507 low_mapping_rate
