Skip to content

Commit 2493a35

Browse files
authored
Issue 49987: Add labkey.experiment.lineage to Rlabkey (#107)
* Add labkey.experiment.lineage API to support getting parent/child relationships for exp objects by LSID * CRAN check fix for DESCRIPTION authors list
1 parent 4ba8b7e commit 2493a35

6 files changed

Lines changed: 119 additions & 6 deletions

File tree

Rlabkey/DESCRIPTION

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
11
Package: Rlabkey
2-
Version: 3.2.3
3-
Date: 2024-06-25
2+
Version: 3.3.0
3+
Date: 2024-08-08
44
Title: Data Exchange Between R and 'LabKey' Server
5-
Author: Peter Hussey
6-
Maintainer: Cory Nathe <cnathe@labkey.com>
5+
Authors@R: c(person(given = "Peter",
6+
family = "Hussey",
7+
role = "aut"),
8+
person(given = "Cory",
9+
family = "Nathe",
10+
role = "cre",
11+
email = "cnathe@labkey.com"))
712
Description: The 'LabKey' client library for R makes it easy for R users to
813
load live data from a 'LabKey' Server, <https://www.labkey.com/>,
914
into the R environment for analysis, provided users have permissions

Rlabkey/NAMESPACE

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ export(labkey.experiment.createRun)
1616
export(labkey.experiment.saveBatch)
1717
export(labkey.experiment.saveRuns)
1818
export(labkey.experiment.SAMPLE_DERIVATION_PROTOCOL)
19+
export(labkey.experiment.lineage)
1920
export(labkey.getModuleProperty)
2021
export(labkey.setModuleProperty)
2122
export(labkey.getBaseUrl)

Rlabkey/NEWS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
Changes in 3.2.3
2+
o Add labkey.experiment.lineage API to support getting parent/child relationships for exp objects by LSID
3+
14
Changes in 3.2.3
25
o Remove deprecated support for JSON based assay plate metadata
36

Rlabkey/R/labkey.experiment.R

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,3 +198,43 @@ labkey.experiment.saveRuns <- function(baseUrl=NULL, folderPath, protocolName, r
198198

199199
return (fromJSON(response, simplifyVector=FALSE, simplifyDataFrame=FALSE))
200200
}
201+
202+
## Get lineage parent/child relationships and information for exp objects by LSID(s)
203+
##
204+
## Optional parameters (passed via options) include:
205+
## parents: (boolean) include parent objects in the lineage
206+
## children: (boolean) include child objects in the lineage
207+
## depth: (integer) the depth of the lineage to retrieve
208+
## expType: the type of experiment objects to retrieve lineage for
209+
## cpasType: the type of CPAS object to retrieve lineage for
210+
## runProtocolLsid: the LSID of the run protocol to retrieve lineage for
211+
## includeProperties: (boolean) include properties in the lineage response
212+
## includeInputsAndOutputs: (boolean) include inputs and outputs in the lineage response
213+
## includeRunSteps: (boolean) include run steps in the lineage response
214+
##
215+
labkey.experiment.lineage <- function(baseUrl=NULL, folderPath, lsids, options = NULL)
216+
{
217+
baseUrl=labkey.getBaseUrl(baseUrl)
218+
219+
## check required parameters
220+
if (missing(folderPath))
221+
stop (paste("A value must be specified for folderPath."))
222+
if (missing(lsids))
223+
stop (paste("A value must be specified for lsids."))
224+
if (!missing(lsids) & !(is.vector(lsids) && is.atomic(lsids)))
225+
stop (paste("The lsids parameter must be a vector data structure."))
226+
if (!missing(options) & !is.list(options))
227+
stop (paste("The options parameter must be a list data structure."))
228+
229+
params <- list(lsids=lsids)
230+
if (!missing(options))
231+
params <- c(params, options)
232+
233+
## normalize the folder path
234+
folderPath <- encodeFolderPath(folderPath)
235+
236+
url <- paste(baseUrl, "experiment", folderPath, "lineage.api", sep="")
237+
response <- labkey.post(url, toJSON(params, auto_unbox=TRUE))
238+
239+
return (fromJSON(response, simplifyVector=FALSE, simplifyDataFrame=FALSE))
240+
}

Rlabkey/man/Rlabkey-package.Rd

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ schema objects (\code{labkey.getSchema}).
1818
\tabular{ll}{
1919
Package: \tab Rlabkey\cr
2020
Type: \tab Package\cr
21-
Version: \tab 3.2.3\cr
22-
Date: \tab 2024-06-25\cr
21+
Version: \tab 3.3.0\cr
22+
Date: \tab 2024-08-08\cr
2323
License: \tab Apache License 2.0\cr
2424
LazyLoad: \tab yes\cr
2525
}
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
\name{labkey.experiment.lineage}
2+
\alias{labkey.experiment.lineage}
3+
\title{Get lineage parent/child relationships for experiment objects}
4+
\description{
5+
Get lineage parent/child relationships and information for exp objects by LSID(s)
6+
}
7+
\usage{
8+
labkey.experiment.lineage(baseUrl=NULL, folderPath,
9+
lsids, options = NULL)
10+
}
11+
\arguments{
12+
\item{baseUrl}{A string specifying the \code{baseUrl} for the labkey server.}
13+
\item{folderPath}{A string specifying the \code{folderPath} to be renamed. Additionally, the container entity id is also valid.}
14+
\item{lsids}{One or more LSID seed values for the experiment objects to retrieve lineage information for.}
15+
\item{options}{(optional) A list containing optional parameters specific to the lineage action.}
16+
}
17+
\details{
18+
This function retrieves lineage parent/child relationships and information for experiment objects by LSID(s).
19+
20+
Optional parameters (passed via options) include:
21+
\itemize{
22+
\item{ \code{parents (boolean)} : include parent objects in the lineage}
23+
\item{ \code{children (boolean)} : include child objects in the lineage}
24+
\item{ \code{depth (integer)} : the depth of the lineage to retrieve}
25+
\item{ \code{expType (string)} : the type of experiment objects to retrieve lineage for}
26+
\item{ \code{cpasType (string)} : the type of CPAS object to retrieve lineage for}
27+
\item{ \code{runProtocolLsid (string)} : the LSID of the run protocol to retrieve lineage for}
28+
\item{ \code{includeProperties (boolean)} : include properties in the lineage response}
29+
\item{ \code{includeInputsAndOutputs (boolean)} : include inputs and outputs in the lineage response}
30+
\item{ \code{includeRunSteps (boolean)} : include run steps in the lineage response}
31+
}
32+
}
33+
\value{
34+
Returns a lineage response object based on the LSID seed values provided. The response object contains:
35+
\itemize{
36+
\item{ \code{seeds} : the LSID of the object(s) requested}
37+
\item{ \code{nodes} : an object with LSID keys for each lineage node and values containing the lineage information}
38+
}
39+
}
40+
41+
\author{Cory Nathe}
42+
\examples{
43+
\dontrun{
44+
45+
library(Rlabkey)
46+
47+
labkey.experiment.lineage(
48+
baseUrl="http://labkey/",
49+
folderPath = "/home/OriginalFolder",
50+
lsids=c("urn:lsid:labkey.com:Sample.519.Blood:23", "urn:lsid:labkey.com:Sample.519.Blood:12"),
51+
options=list(
52+
parents=TRUE,
53+
children=TRUE,
54+
depth=10,
55+
expType="Material",
56+
includeProperties=TRUE,
57+
includeInputsAndOutputs=FALSE,
58+
includeRunSteps=FALSE
59+
)
60+
)
61+
62+
}
63+
}
64+
\keyword{IO}

0 commit comments

Comments
 (0)