Skip to content

Commit

Permalink
cohort class now holds information about the saved columns
Browse files Browse the repository at this point in the history
  • Loading branch information
sk-sahu committed Nov 10, 2020
1 parent 33e6294 commit bc747d9
Show file tree
Hide file tree
Showing 4 changed files with 148 additions and 25 deletions.
8 changes: 6 additions & 2 deletions R/cb_class.R
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#' @slot desc cohort description.
#' @slot fields Filters.
#' @slot more_fields Filter related information.
#' @slot columns All the columns
#'
#' @name cohort-class
#' @rdname cohort-class
Expand All @@ -22,7 +23,8 @@ setClass("cohort",
name = "character",
desc = "character",
fields = "list",
more_fields = "list")
more_fields = "list",
columns = "list")
)

.get_cohort_info <- function(cloudos, cohort_id) {
Expand Down Expand Up @@ -61,7 +63,8 @@ cb_load_cohort <- function(cloudos, cohort_id){
name = my_cohort$name,
desc = my_cohort$description,
fields = my_cohort$fields,
more_fields = my_cohort$moreFields
more_fields = my_cohort$moreFields,
columns = my_cohort$columns
)
return(cohort_class_obj)
}
Expand All @@ -72,5 +75,6 @@ setMethod("show", "cohort",
cat("Cohort ID: ", object@id, "\n")
cat("Cohort Name: ", object@name, "\n")
cat("Cohort Description: ", object@desc, "\n")
cat("Number of filters applied: ", length(object@fields), "\n")
}
)
2 changes: 2 additions & 0 deletions man/cohort-class.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -320,46 +320,164 @@
"instance15Name": "",
"instance16Name": ""
}
},
{
"id": 70,
"instance": 0,
"array": {
"type": "all",
"value": 0
},
"field": {
"_id": "5f8f1dbbaaeccb0065837594",
"bucket500": false,
"bucket1000": false,
"bucket2500": false,
"bucket5000": false,
"bucket300": false,
"bucket10000": false,
"categoryPathLevel1": "COVID",
"id": 70,
"instances": 1,
"name": "Acute flag",
"type": "bars",
"Sorting": "",
"valueType": "Categorical multiple",
"units": "",
"coding": "14",
"description": "Set true (1) if the requesting organisation is from an organisation known to provide acute (emergency) care otherwise not true (0).",
"descriptionParticipantsNo": "6647",
"link": "",
"array": 26,
"descriptionStability": "",
"descriptionCategoryID": "",
"descriptionItemType": "",
"descriptionStrata": "Main 100k Programme",
"descriptionSexed": "",
"orderPhenotype": "",
"instance0Name": "",
"instance1Name": "",
"instance2Name": "",
"instance3Name": "",
"instance4Name": "",
"instance5Name": "",
"instance6Name": "",
"instance7Name": "",
"instance8Name": "",
"instance9Name": "",
"instance10Name": "",
"instance11Name": "",
"instance12Name": "",
"instance13Name": "",
"instance14Name": "",
"instance15Name": "",
"instance16Name": "",
"values": {
"0": "FALSE",
"1": "TRUE"
}
}
}
],
"moreFields": [
{
"fieldId": 206,
"fieldId": 22,
"instance": [
0
],
"range": {
"from": "2015-05-25",
"to": "2016-04-07"
},
"finished": true
},
{
"fieldId": 50,
"instance": [
0
],
"value": [
"Cardiovascular disorders",
"Dermatological disorders",
"Dysmorphic and congenital abnormality syndromes"
"Father",
"Mother"
],
"finished": true
}
],
"fields": [
{
"field": {
"_id": "5f8f1dbbaaeccb0065837666",
"_id": "5f8f1dbbaaeccb00658375c0",
"bucket500": false,
"bucket1000": false,
"bucket2500": false,
"bucket5000": false,
"bucket300": false,
"bucket10000": false,
"categoryPathLevel1": "Rare disease",
"categoryPathLevel2": "Participant disease",
"id": 206,
"categoryPathLevel1": "Basic characteristics",
"id": 22,
"instances": 1,
"name": "Disease group",
"name": "Date of consent",
"type": "histogram",
"Sorting": "ASC_date",
"valueType": "Date",
"units": "",
"coding": "",
"description": "Date of the clinical event or observation being reported e.g. date biopsy was taken",
"descriptionParticipantsNo": "89132",
"link": "https://cnfl.extge.co.uk/pages/viewpage.action?pageId=147659370",
"array": 1,
"descriptionStability": "",
"descriptionCategoryID": "",
"descriptionItemType": "",
"descriptionStrata": "Main 100k Programme",
"descriptionSexed": "",
"orderPhenotype": "",
"instance0Name": "",
"instance1Name": "",
"instance2Name": "",
"instance3Name": "",
"instance4Name": "",
"instance5Name": "",
"instance6Name": "",
"instance7Name": "",
"instance8Name": "",
"instance9Name": "",
"instance10Name": "",
"instance11Name": "",
"instance12Name": "",
"instance13Name": "",
"instance14Name": "",
"instance15Name": "",
"instance16Name": ""
},
"instances": [
0
],
"createAt": 1605026046066,
"updatedAt": 1605026046066
},
{
"field": {
"_id": "5f8f1dbbaaeccb00658375db",
"bucket500": false,
"bucket1000": false,
"bucket2500": false,
"bucket5000": false,
"bucket300": false,
"bucket10000": false,
"categoryPathLevel1": "Basic characteristics",
"id": 50,
"instances": 1,
"name": "Biological relationship to proband",
"type": "bars",
"Sorting": "",
"valueType": "Categorical multiple",
"units": "",
"coding": "",
"description": "Top-level classification of rare diseases (project specific)",
"descriptionParticipantsNo": "39913",
"description": "Biological Relationship to Proband",
"descriptionParticipantsNo": "89132",
"link": "https://cnfl.extge.co.uk/pages/viewpage.action?pageId=147659370",
"array": 5,
"array": 1,
"descriptionStability": "",
"descriptionCategoryID": "",
"descriptionItemType": "",
Expand Down Expand Up @@ -387,8 +505,8 @@
"instances": [
0
],
"createAt": 1604069383405,
"updatedAt": 1604069383405
"createAt": 1605026046066,
"updatedAt": 1605026046066
}
]
}
17 changes: 8 additions & 9 deletions tests/testthat/test_cohort.R
Original file line number Diff line number Diff line change
@@ -1,23 +1,22 @@
# capture_requests({
# # set a dummy cloudos credentials
# my_cloudos <- connect_cloudos(base_url = "http://cohort-browser-766010452.eu-west-1.elb.amazonaws.com/api/",
# my_cloudos <- connect_cloudos(base_url = "http://cohort-browser-dev-110043291.eu-west-1.elb.amazonaws.com/api",
# auth = Sys.getenv("test_cloudos_apikey"),
# team_id = "5f046bf6c132dd15fdd1a525")
# team_id = Sys.getenv("test_cloudos_team_id"))
# # set a dummy cohort object
# my_cohort <- cb_load_cohort(my_cloudos, cohort_id = "5f6228133097cc7a6504fb76")
# my_cohort <- cb_load_cohort(my_cloudos, cohort_id = "5f9af3793dd2dc6091cd17cd")
#
# expect_s4_class(my_cohort, "cohort")
# })

with_mock_api({
test_that("Get a cohort class method", {

# set a dummy cloudos credentials
my_cloudos <- connect_cloudos(base_url = "http://cohort-browser-766010452.eu-west-1.elb.amazonaws.com/api/",
auth = "apikey",
team_id = "5f046bf6c132dd15fdd1a525")
# set a cohort object
my_cohort <- cb_load_cohort(my_cloudos, cohort_id = "5f6228133097cc7a6504fb76")
my_cloudos <- connect_cloudos(base_url = "http://cohort-browser-dev-110043291.eu-west-1.elb.amazonaws.com/api",
auth = Sys.getenv("test_cloudos_apikey"),
team_id = Sys.getenv("test_cloudos_team_id"))

my_cohort <- cb_load_cohort(my_cloudos, cohort_id = "5f9af3793dd2dc6091cd17cd")

expect_s4_class(my_cohort, "cohort")
})
Expand Down

0 comments on commit bc747d9

Please sign in to comment.