Changelog
osp.snapshots 1.1.0
New features
-
create_protocol()gainsdose(withdose_unit, default"mg"),start_time(withstart_time_unit, default"h"), andend_timeplain arguments for the Simple-Protocol dosing settings, as a validated, self-documenting alternative to hand-building the equivalentInputDose/Start time/End timeentries inparameters(#157). -
create_schema()gains plain argumentsnumber_of_repetitions,time_between_repetitions(with unittime_between_repetitions_unit, default"h"), andstart_time(with unitstart_time_unit, default"h") for the schema-level repetition parameters, so callers no longer hand-writecreate_parameter()entries with PK-Sim’s internal names; theparameterslist still works for anything else, and supplying a value both ways is an error (#167). -
create_schema_item()gains promoteddose(withdose_unit, default"mg") andstart_time(withstart_time_unit, default"h") arguments, mirroringcreate_output_interval()andcreate_event_selection(); the dose is written as a singleInputDoseparameter whose unit selects the dose family, and supplying a promoted argument together with the matchingparametersentry is an error (#168). -
fraction_unbound()gains aspeciesargument (default"Human", validated againstospsuite::Species) and now emits aSpeciesfield on the fraction-unbound alternative, which PK-Sim requires to load the snapshot (#156). -
load_snapshot()andSnapshot$new()gain anupgradeargument (defaultFALSE) that migrates a below-floor PK-Sim snapshot (Version 74-78) up to the installed core’s version via a PK-Sim round trip; without it, such a snapshot reports how to migrate and does not load (#161). -
load_snapshot()now supports PK-Sim v13 snapshots (Version 81), reports their PK-Sim version, and rejects snapshots newer than it supports (Version 82+) with a clear error (#161).
Minor improvements and fixes
-
create_population()now requiresnumber_of_individualsto be a whole number between 2 and 10000, matching the bounds PK-Sim enforces when creating a population (#170). -
create_schema_item()(andcreate_protocol(),Protocol$application_type, andSchemaItem$application_type) now validateapplication_typeagainst PK-Sim’s canonical four values (Oral,Intravenous,IntravenousBolus,UserDefined), newly acceptingUserDefinedand no longer accepting the previously listed non-canonical values (IntravenousInfusion,Intramuscular,Subcutaneous,Dermal,Rectal,Inhalation,Intraperitoneal);target_organandtarget_compartmentare now accepted only whenapplication_typeisUserDefined(#171). -
create_snapshot()now authors the current PK-Sim v13 snapshot version (Version 81) instead of80, ordering the top-levelNamebeforeVersionand emitting the newCheckNegativeValuessolver field when a simulation is added (#161). -
get_compounds_dfs()no longer errors on a reference-pH solubility alternative whoseReference pHparameter is omitted (as PK-Sim does when it holds the default), defaulting the reference pH to PK-Sim’s default of7. -
get_compounds_dfs()no longer errors on a compound with no parameters to read: a process with an emptyParameterslist (as PK-Sim exports for a parameterless process such asGlomerularFiltration) is omitted from the tibbles, and a compound with no top-levelParameters(for example one built from a value-object alternative alone) reads back without a molecular-weight row. -
load_snapshot()warns, rather than fails, when a supported snapshot is newer than the installedospsuitecore, since it may not load or run there (#161).
osp.snapshots 1.0.0
Breaking changes
-
AdvancedParameter$distribution_typeis now validated against the distribution-type enum (Normal,LogNormal,Uniform,Discrete,Unknown). -
compound$calculation_methodsreturns aCalculationMethodsR6 object instead of a plain list with classcompound_calculation_methods. Read the names withcompound$calculation_methods$namesand mutate with$add(name),$remove(name);$lengthreports the count (#30). -
Compound$is_small_moleculenow requires a single logical value (orNULL). -
Compound$plasma_protein_binding_partnerandcreate_compound()’splasma_protein_binding_partnerargument are now validated against the binding-partner enum (Unknown,Albumin,Glycoprotein). -
compound$processesreturns a flat named list ofProcessR6 objects (duplicate names disambiguated with_{n}). Filter byprocess$categoryto recover the equivalent of the deprecated per-category accessors (#40). -
CompoundProperties$calculation_methodsnow requires a character vector (orNULL). -
create_compound(),create_individual(), andcreate_observed_data()take value-object helpers (lipophilicity(),fraction_unbound(),solubility(),intestinal_permeability(),permeability(),age(),weight(),height(),gestational_age(),time(),values(),error()) for their value/unit/name fields instead of the per-field_value/_unit/_namescalar arguments; for examplecreate_compound(name = "X", lipophilicity = lipophilicity(2.5)). The matchingCompound/Individual/OriginDatafields now require the helper as well; a bare scalar (for exampleindividual$age <- 30orcompound$lipophilicity <- 2.5) is rejected (#133, #140). -
create_individual()now emits the currentDiseaseobject ({ Name, Parameters }) underOriginData$Diseaseinstead of the legacyDiseaseState/DiseaseStateParameterspair, matchingcreate_expression_profile(); loaded legacy snapshots still read back correctly (#151). -
create_parameter()writes the identifier todata$Namefor plain parameters (nopathargument) and todata$Pathfor path-bearing parameters (withpathargument). Previously every result carrieddata$Path. Passpath = ...to get a path-bearing parameter; passname = ...to get a plain one (#52). -
create_protocol()(and theProtocol$dosing_intervalsetter) now validatedosing_intervalagainst the fixedDosingIntervalIdvalues (Single,DI_6_6_6_6,DI_6_6_12,DI_8_8_8,DI_12_12,DI_24) and error early on an unknown value, matching howapplication_typeis validated (#151). -
error()now validatestypeagainst the schemaAuxiliaryTypevalues (ArithmeticStdDev,GeometricStdDev,ArithmeticMeanPop,GeometricMeanPop) and no longer accepts the off-schema"ArithmeticStdErr"(#151). -
get_compounds_dfs()returns a list with two tibbles,propertiesandprocesses, instead of a single combined tibble. Update callers fromdf <- get_compounds_dfs(snap)todfs <- get_compounds_dfs(snap); df <- dfs$properties, or switch to the new long-formdfs$processes(#40). - The identity-name setters across building blocks and selections (
Compound$name,Population$name,Protocol$name,Schema$name,SchemaItem$name,Event$name/$template,Observer$name,ObserverSet$name,Process$internal_name/$data_source/$molecule/$metabolite/$species,CompoundProperties$name,CompoundGroupSelection$group_name/$alternative_name,CompoundProcessSelection$name/$molecule_name/$metabolite_name/$compound_name/$systemic_process_type,FormulationSelection$name/$key,ObserverSetSelection$name,ProtocolSelection$name,EventSelection$name,Individual$name) now reject empty,NA, or non-scalar strings. -
load_snapshot()now requires PK-Sim v11.2 snapshots or newer (Version >= 79). Re-export older projects from PK-Sim v11.2+ before loading (#52). -
Observer$dimensionnow requires a non-empty string (orNULL). -
OutputMapping$path,$observed_data,$scaling,$weight,$weights, and the matchingcreate_output_mapping()arguments, are now validated ($scaling/scalingagainst theLinear/Logenum on both the setter and the factory). - The parameters setters (
Protocol$parameters,Individual$parameters,Schema$parameters,SchemaItem$parameters,Formulation$parameters,Event$parameters) now require a list (orNULL). -
Parameter$dataandExpressionProfile$dataare now read-only; mutate the parameter/profile through its typed fields instead. -
Parameter$unitnow requires a single non-empty string (orNULL). -
Population$age_range,$weight_range,$height_range,$gestational_age_range, and$bmi_rangenow validate the range’s unit against the field’s dimension. -
Population$number_of_individualsnow requires a positive whole number (previously any positive number). -
Protocol$application_typeandSchemaItem$application_typenow match the canonical PK-Sim application types thatcreate_protocol()andcreate_schema_item()already validated against. -
Protocol$time_unitandcreate_protocol()’stime_unitargument are now validated against theTimedimension. -
Simulation$allow_agingnow requires a single logical value (orNULL). -
SolverSettingsfields (abs_tol,rel_tol,use_jacobian,h0,h_min,h_max,mx_step) are now validated percreate_solver_settings()’s existing rules.
New features
-
add_simulation()is the entry point for building a simulation: with the snapshot in hand it constructs aSimulationfrom named arguments (name,individual/population,compounds, …), resolves the references, and derives defaults (calculation methods from the compound, the formulation key from the protocol’s slot, alternatives from each group’s default) before attaching. Configure each compound inline throughcompounds = list(list(name =, protocol =, formulation =, processes =, calculation_methods =, alternatives =, ...)): select a specific alternative by friendly property name and label (alternatives = c(solubility = "FaSSIF"), overriding the derived default for that group only) or bind a multi-slot protocol’s formulations explicitly (formulation = c(Formulation = "Oral solution", "Formulation 2" = "IV solution")); a namedformulationmap that names a slot key the referenced protocol does not have is not an error, only an informational message, since PK-Sim itself rejects an unbound or mis-bound slot at load time. Unresolved references to other building blocks (individual, population, compounds, events, observer sets, observed data, protocols, formulations) trigger one informational warning per simulation; the add proceeds either way (#94, #135, #144). -
add_*()mutators now accept either a single building block or a list of building blocks, mirroringremove_*()which has accepted a character vector of names since #66. Success messages on both sides now uniformly reportAdded N kind(s)/Removed N kind(s)(#92). -
add_individual()warns once per individual when it references expression profiles (by compositeMolecule|Species|Categoryid) that are not in the snapshot; the add proceeds either way (#135). -
age(),weight(),height(),gestational_age(),lipophilicity(),fraction_unbound(),solubility(),intestinal_permeability(),permeability(),time(),values(), anderror()build small value objects that bundle a value, its unit, and any field-specific extras for thecreate_*()factory arguments; each owns its default unit and validates a supplied unit against the field’s dimension. The five compound physicochemical-property helpers (lipophilicity(),fraction_unbound(),solubility(),intestinal_permeability(),permeability()) also take adefaultargument to mark which alternative in a list is the group’s default (#133, #147). -
as_tibbles()converts any building-block collection to a tibble through one entry point, returning either a bare tibble ("protocols","observed_data") or a named list of related tibbles (every other kind).kindis optional and accepts a character vector: omit it (or passNULL) to get all kinds as a named list keyed by kind, or pass several kinds to get just that subset. The nine existingget_*_dfs()functions remain available as thin wrappers (#36, #137). -
compound$calculation_methodsandindividual$origin_data$calculation_methodsreturn aCalculationMethodsobject you can inspect ($names,$length) and mutate ($add(),$remove()) (#30). -
compound$processesreturns a named list ofProcessobjects, each exposinginternal_name,data_source,molecule,metabolite,species,parameters, and a derivedcategory(#40). -
create_compound()builds a compound from named arguments, with validation onmolecular_weight_unitagainstospsuite::ospUnits$"Molecular weight"(#27, #48). It sets the physicochemical properties through value-object helpers:lipophilicity(),fraction_unbound(),solubility()(expressing reference pH, gain per charge, or a pH/value table),intestinal_permeability(), andpermeability(), pluspKaandprocesses; each property argument also accepts a list of these objects to define several named alternatives, letting exactly one be marked the group default via its helper’sdefault = TRUEargument (the first element is the default when none is marked); the matchingCompoundfields$lipophilicity,$fraction_unbound,$solubility,$intestinal_permeability, and$permeabilityare writable and require the same helper objects (single or a list for named alternatives) so a loaded compound can be mutated.$pka_typesis writable with a list oflist(type =, value =)entries (or a rawPkaTypelist), and$processesis writable with a list ofProcessobjects (or raw process lists). Attach withadd_compound(), remove by name withremove_compound()(#39, #115, #133, #140, #144, #147). -
create_compound_group_selection(),create_compound_process_selection(),create_compound_properties(),create_event_selection(),create_formulation_selection(),create_observer_set_selection(),create_output_interval(),create_output_mapping(),create_output_schema(),create_protocol_selection(), andcreate_solver_settings()build aSimulation’s supporting structures from named arguments, for use as the escape hatch toadd_simulation()and for hand-built configurations (#94). -
create_descriptor_condition()builds a container criterion (Tag, and an open-stringTypesuch as"InContainer"or"MatchTag") for an observer’s container criteria (#119). -
create_event()builds an event from a template name and an optional list of parameter overrides (#27). Attach withadd_event(), remove withremove_event()(#39). -
create_expression_profile()builds an expression profile, requiring molecule, species, category, and type, and acceptsexpression(per-organ relative expression as a data frame of container rows or a raw list) anddisease(a disease state); theExpressionProfileobject gains read/writeexpressionanddiseasebindings so a loaded profile can be read and mutated (#27, #116). -
create_formula_reference()builds a formula reference (Alias,Path, optionalDimension) for an observer’s formula (#119). -
create_formulation()accepts an arbitraryFormulationTypestring and a rawparametersform (a list ofcreate_parameter()objects orlist(Name=, Value=, ...)dicts), so you can author unknown formulation types and set arbitrary parameters by name, per-parameterValueOrigin, and a customTableFormulaon any type; the curated alias form is unchanged andFormulation$formulation_typenow accepts any non-empty string (#120). -
create_individual()sets the demographic fields through value-object helpers (age(),weight(),height(),gestational_age()), and gainsexpression_profiles,description, andparametersarguments to attach expression-profile references, a description, and localized parameter overrides at creation time; theIndividual$expression_profilesbinding is now writable and a new read/writeIndividual$descriptionbinding is available. The demographicIndividualfields require the same helper objects (#117, #133, #140). -
create_molecule_list()builds an observer’s molecule list fromfor_all,include, andexclude(#119). -
create_observed_data()builds anospsuite::DataSetfrom thetime(),values(), and optionalerror()series value-object helpers. The values dimension is required and is supplied tovalues(), where it gates unit validation (#27, #48, #133). Attach withadd_observed_data(), remove withremove_observed_data()(#39). -
create_observer()builds a single observer for an observer set, with arguments for name, type, dimension, formula, formula references, container criteria, and molecule list.Observernow exposes a lossless writablecontainer_criteriafield (preserving each criterion’sType), a writableformula_referencesfield, and a writablemolecule_listfield, and validatestypeagainstAmount/Containeron assignment (#119). -
create_observer_set()builds an observer set from anameand a list of observers (#43). Attach withadd_observer_set(), remove withremove_observer_set()(#38). -
create_parameter()gains asource_methodargument that carries the value-origin determination method toValueOrigin.Method, so it round-trips (#151). -
create_population()builds a population, takingRangeobjects for age, weight, height, and BMI bounds, and acceptingdescription,gestational_age_range,disease_state_parameters, and anindividualcomposed fromcreate_individual()to fully configure the population’s base individual.number_of_individualsmust be a positive integer;proportion_of_femalesmust be a length-1 number.Populationobjects gain read/writedescription,gestational_age_range, anddisease_state_parametersbindings and a read-onlyindividualbinding exposing the base individual (#27, #48, #118). Attach withadd_population()(#39). -
create_process()builds a compound process;internal_nameanddata_sourceare validated (#40). See?create_processfor the list of supportedinternal_namevalues. -
create_protocol()builds a Simple or Advanced protocol. Passschemasto build an Advanced protocol (acceptsSchemaobjects fromcreate_schema()or raw lists); mixing Simple-only fields (application_type,dosing_interval, …) withschemaserrors out (#27, #48, #54). Attach withadd_protocol(), remove withremove_protocol()(#39). -
create_schema()andcreate_schema_item()build the repeatable blocks and individual applications used inside an Advanced protocol.application_typeon a schema item is validated against the canonical PK-Sim application types (#54). -
create_snapshot()creates an empty snapshot carrying the current supported PK-Sim version, optionally named and described, as a snapshot-level counterpart toload_snapshot()andexport_snapshot()(#112). -
get_default_alternative()returns the name of the default alternative in a compound physicochemical-property group, for exampleget_default_alternative(compound$solubility); printing such a group also flags the default alternative with(Default)(#147). -
individual$origin_datareturns anOriginDataobject holding the demographic starting point of the individual (species, population, gender, age, weight, height, gestational age, calculation methods, optional disease state) (#30). -
ObserverSetobjects are now fully supported end to end (load, mutate, convert, export). Each exposes its observers as a named list ofObserverobjects withname,type,dimension,formula(the fullExplicitFormulalist),formula_expression,formula_dimension,formula_references, andcontainer_tags.get_observer_sets_dfs()returns two tibbles (observer_setsfor set-level rows,observersjoinable back viaobserver_set_id/observer_set_name); theobserverstibble carriesformula_expression,formula_dimension, andformula_referencescolumns alongsidename,type,dimension, andcontainer_tags(#38, #42, #76, #79). -
protocol$schemasreturns a named list ofSchemaobjects, each exposing$itemsas a list ofSchemaItemobjects (application type, formulation key, target organ and compartment, parameters) (#29). -
remove_simulation()removes one or more simulations from aSnapshotby name (#94). -
Simulationis now a first-class building block wrapping the simulation slice of a snapshot with R6 accessors for solver settings, output schemas, compound configurations, event and observer-set selections, observed-data references, output mappings, andLocalizedParameteroverrides. Simulations are built throughadd_simulation()and loaded from snapshots; existing simulations are mutated in place through their live bindings. Four post-run fields (Interactions,AlteredBuildingBlocks,IndividualAnalyses,PopulationAnalyses) are preserved byte-equivalent through$data, and construction enforces an XOR on$individualand$populationso that exactly one subject is configured (#94). - Parameters that live in a parameter tree (under an
Individual,ExpressionProfile, orSimulation) are nowLocalizedParameterobjects, identified by a pipe-separated path. Pre-v11Applications|...segments are migrated toEvents|...on load.create_parameter()routes toLocalizedParameterwhen called with apathargument (#31).
Minor improvements and fixes
-
as_tibbles(snapshot, "protocols")(and the legacyget_protocols_dfs()wrapper) now returns the same 13 columns whether the snapshot has any protocols or not. Previously the empty-state path returned an 18-column tibble that disagreed with the populated path, breakingbind_rows()across mixed snapshots (#56). -
create_compound()output can now be printed whenis_small_moleculeis left unset. Previously printing such a compound aborted with “missing value where TRUE/FALSE needed”; the type line is now omitted instead (#115). -
create_protocol()now validatesapplication_typeagainst the canonical PK-Sim application types and errors early on an invalid value, matchingcreate_schema_item()(#121). -
export_snapshot()now serializesDataSetobjects attached at runtime viaadd_observed_data(), so a snapshot built fromcreate_observed_data()andadd_observed_data()round-trips throughexport_snapshot()andload_snapshot(). Entries that were already present in the loaded snapshot are still replayed from the original JSON slice, which means post-load mutations to aDataSet(e.g. changingxUniton an entry insnapshot$observed_data) are not reflected on export (#35, #96). -
loadDataSetFromSnapshot()now preserves the observed-data time unit (BaseGrid$Unit) on the resultingDataSet$xUnitfor every ospsuite Time unit, including"day(s)","week(s)","month(s)","year(s)", and"ks". Previously only"h","min", and"s"survived and any other unit silently reverted to"h", misplacing time points (for example a 24x error forday(s)); this also affectedcreate_observed_data(time_unit = ...)(#104). -
Parameter$unitvalidates only shape (a single non-empty string); dimension-aware unit validation is opportunistic since a bareParametercarries no dimension.Range$unitremains unvalidated on the class itself; unit validation happens at thePopulationrange setters that consume aRange.Population$bmi_range’s unit,Compound$plasma_protein_binding_partner,AdvancedParameter$distribution_type, theFormulationcurated unit sub-parameters, andCompoundProcessSelection$systemic_process_typeare validated at the strongest constraint confirmable in code; each documents its own fallback (#140). -
Population$egfr_rangenow persists into the population settings, so an eGFR range set on a population survives export (#118). -
print()onsnapshot$simulationsno longer errors. Previously it aborted because thesimulation_collectionkind was missing its print-dispatch methods, added for every other building-block collection (#149). -
remove_expression_profile(),remove_formulation(),remove_individual(),remove_observed_data(), andremove_population()now report the actual number of entries removed instead of the length of the input vector, so the success message reads correctly when a requested name is not present in the snapshot (#66). - Building-block collections now share a
snapshot_collectionS3 class with a single genericprint()method. The existing per-kind classes (compound_collection,individual_collection, …) are preserved as marker classes (#34). - Observed data removed via
remove_observed_data()is now dropped from the exported snapshot. Previously the export reused the full originalObservedDatalist whenever the lazy cache had been touched, re-introducing the removed entries on round-trip. The same fix applies to every building-block section: clearing a collection viaremove_individual(),remove_formulation(),remove_population(), orremove_expression_profile()now writes an empty section on export instead of falling back to the original entries (#35, #59). - Single-element JSON arrays remain arrays on export/import, allowing exported snapshots to load in PK-Sim (#23).
- The eight category-keyed compound accessors (
$protein_binding_partners,$metabolizing_enzymes,$hepatic_clearance,$transporter_proteins,$renal_clearance,$biliary_clearance,$inhibition,$induction) are soft-deprecated. Usecompound$processes(filter byprocess$category) or the long-formprocessestibble returned byget_compounds_dfs()(#40).
osp.snapshots 0.2.2
osp.snapshots 0.2.1
Minor improvements and bug fixes
New
osp_models()function to browse and discover available OSP building block templates from the OSPSuite Community repository.Fixed bug in dataframe generation functions that caused errors when combining empty or NULL building block data using
bind_rows().
osp.snapshots 0.2.0
New
load_snapshot()function to import PKSIM project snapshots from JSON files, URLs, or predefined templates.New
export_snapshot()function to save modified snapshots back to JSON files for import into PKSIM.Complete R6 class implementations for all major PKSIM building blocks:
Individual,Compound,Formulation,Population,Protocol,Event,ExpressionProfile, andParameter.New data frame conversion functions for all building block types:
get_individuals_dfs(),get_compounds_dfs(),get_formulations_dfs(),get_populations_dfs(),get_protocols_dfs(),get_events_dfs(),get_expression_profiles_dfs(), andget_observed_data_dfs().New creation functions:
create_individual(),create_formulation(), andcreate_parameter()for building new building blocks.New management functions:
add_individual(),add_formulation(),add_expression_profile(),remove_individual(),remove_formulation(),remove_population(), andremove_expression_profile().Full integration with
ospsuite::DataSetobjects for observed data.Comprehensive input validation for species, populations, genders, and units.
Time conversion utilities between OSPSuite and R
lubridateformats.Structured print methods for all building block classes.