Convert LFQData + ProteinAnnotation to AnnData with round-trip metadata
Source:R/preprocess_DIANN_anndata.R
preprocess_anndata_from_lfq.RdBuilds an AnnData object from LFQData and ProteinAnnotation, with the
prolfquapp uns namespace for lossless round-trip via
LFQData_from_anndata.
Value
anndataR::AnnData object
Details
Handles both protein-level (hierarchyDepth=1) and peptide-level (hierarchyDepth=2) data. For peptide-level data, var contains one row per feature (peptide) with protein annotation joined in.
Examples
if (requireNamespace("anndataR", quietly = TRUE)) {
# Protein-level
res <- sim_data_protAnnot(Nprot = 10, PROTEIN = TRUE)
adata <- preprocess_anndata_from_lfq(res$lfqdata, res$pannot, "simulated")
adata # 12 obs x 10 var
# Peptide-level (multiple peptides per protein)
res2 <- sim_data_protAnnot(Nprot = 10, PROTEIN = FALSE)
adata2 <- preprocess_anndata_from_lfq(res2$lfqdata, res2$pannot, "simulated")
adata2 # 12 obs x ~28 var (peptides)
# Round-trip back to LFQData
back <- LFQData_from_anndata(adata2)
back$lfqdata$hierarchy_counts()
}
#> creating sampleName from fileName column
#> completing cases
#> completing cases done
#> setup done
#> Warning: no exp_nr_children column specified, computing using nr_obs_experiment function
#> creating sampleName from fileName column
#> completing cases
#> completing cases done
#> setup done
#> Warning: no exp_nr_children column specified, computing using nr_obs_experiment function
#> # A tibble: 1 × 3
#> isotopeLabel protein_Id peptide_Id
#> <chr> <int> <int>
#> 1 light 10 28