Package 'tidysbml'

Title: Extract SBML's data into dataframes
Description: Starting from one SBML file, it extracts information from each listOfCompartments, listOfSpecies and listOfReactions element by saving them into data frames. Each table provides one row for each entity (i.e. either compartment, species, reaction or speciesReference) and one set of columns for the attributes, one column for the content of the 'notes' subelement and one set of columns for the content of the 'annotation' subelement.
Authors: Veronica Paparozzi [aut, cre] , Christine Nardini [aut]
Maintainer: Veronica Paparozzi <[email protected]>
License: CC BY 4.0
Version: 1.1.0
Built: 2024-10-31 05:47:09 UTC
Source: https://github.com/bioc/tidysbml

Help Index


Create a dataframe for the type of entity selected

Description

It takes in input a sbml-converted list zoomed at one 'listOf' level and produces one dataframe containing one row for each entity (i.e. either species, reaction or compartment) and columns for the attributes, notes and annotation content.

Usage

as_df(sbml_list_listOf)

Arguments

sbml_list_listOf

sbml converted into a list restricted to a 'listOf' level (e.g. listOfSpecies), a list

Details

Input list may be obtained using sbml_as_list() with the argument 'component' equal to 'species', 'reactions' or 'compartments', which returns a list zoomed at 'listOfSpecies', 'listOfReactions' or 'listOfCompartments' level, respectively. If the 'listOf' selected is 'listOfReactions' it returns one more dataframe: the first one with one row for each reaction, and the extra one with one row for each species involved in each reaction (i.e. entities called 'speciesReference' in the sbml). Each dataframe contains at least one column, since some attributes are mandatory, and also notes and annotation columns, if their content is not empty. If the dataframe is missing it means the sbml does not contain such information (i.e. no data about those entities).

Value

one dataframe (or a list of two dataframes) containing information about the entities in the input list

Examples

filepath <- system.file("extdata", "R-HSA-8937144.sbml", package = "tidysbml")

sbml_list <- sbml_as_list(filepath, "species")
df <- as_df(sbml_list) ## returns one dataframe with data about the species saved in the sbml document

sbml_list <- sbml_as_list(filepath, "reactions")
df <- as_df(sbml_list) ## returns one list containing two dataframe with data about the reactions and the speciesReferences listed in the sbml document

Create a list of dataframes (full extraction)

Description

It takes in input a sbml file (or sbml list) and returns a list of maximum 3 components, depending on which entities are actually reported in the sbml document. The first component contains the dataframe for listOfCompartments data, the second one for listOfSpecies data while the third component contains maximum two dataframes about reactions info (one with reactions data and the other one with data about the species involved in each reaction).

Usage

as_dfs(sbml, type = "file")

Arguments

sbml

either the path of the sbml file or the sbml already converted into a list, that is either a character string or a list respectively

type

description about the type of the first argument (i.e. 'file' or 'list'), a character string

Details

This is the main function of the package. It comprehends all the other functions. Since it incorporates also the sbml_as_list() function it is possible to insert as input either the sbml path or the sbml already converted into a list. This is set up using the argument 'type' which has to be 'file' or 'list', respectively.

Value

a list of dataframes

Examples

filepath <- system.file("extdata", "R-HSA-8937144.sbml", package = "tidysbml")

sbml_list <- sbml_as_list(filepath)
as_dfs(sbml_list, type = "list") ## returns a list of dataframes, giving in input the sbml already converted into a list

as_dfs(filepath, type = "file") ## returns a list of dataframes, giving in input the sbml path

Create R list from sbml file

Description

This function converts a sbml file into a R list.

Usage

sbml_as_list(file, component = "all")

Arguments

file

path for the sbml file to be loaded

component

description of which entities (i.e. sbml level) have to be extracted into a list, a character string

Details

By selecting the argument 'component' as 'all' it returns the sbml-converted list looking at the highest level (i.e. 'sbml' tag), whereas if it equals either 'species', 'reactions' or 'compartments', the list can be restricted to the species/reactions/compartments level. The first option permits to use the resulting list as input for as_dfs() function, while the other options provide the input for as_df() function.

Value

sbml converted into a R list

Examples

filepath <- system.file("extdata", "R-HSA-8937144.sbml", package = "tidysbml")

sbml_list <- sbml_as_list(filepath, "all") ## returns the R list with the entire sbml model

sbml_as_list(filepath, "species") ## returns the R list restricted to the list of species

sbml_as_list(filepath, "reactions") ## returns the R list restricted to the list of reactions

sbml_as_list(filepath, "compartments") ## returns the R list restricted to the list of components

Validate SBML schema

Description

This function returns result of schema validation for the SBML document inserted.

Usage

sbml_validate(sbml_file)

Arguments

sbml_file

xml object, e.g. output of 'xml2::read_xml()'

Details

Validation is executed for SBML documents up to Level 2 Version 5, by using XML schemas provided in http://sbml.org/documents/specifications/. Otherwise returns error.

Value

a boolean value with error details as attribute

Examples

filepath <- system.file("extdata", "MODEL1012080000.xml", package = "tidysbml")

xml_file <- xml2::read_xml(filepath)

sbml_validate(xml_file) ## returns a boolean value as result of validation in addition to attribute containing errors details