Closed JSchoenbachler closed 2 years ago
https://github.com/hugheylab/phers/blob/adc2ca85fe38a92bf4795ac4a946e15c312290e2/R/phers.R#L81-L82
Spacing
demos[, person_ID := as.character(person_ID)]
phecodes[, person_ID := as.character(person_ID)]
https://github.com/hugheylab/phers/blob/adc2ca85fe38a92bf4795ac4a946e15c312290e2/R/phers.R#L96
You should use setnames
to just rename the column since you don't use the ID
column after this.
Instead of 2 R scripts with one function in each (the map_*.R
scripts), you should make a utils.R
script that contains both of those functions. A utils.R
script is great for holding functions that don't really have another script they would logically fit in with and/or unexported functions you use within the package but don't care for others to have access to.
You only need to import packages and functions once. Keep them in the phers.R
script and remove here.
And I don't think .N
needs to be imported, since it's not a function.
Never use ::
within a package, but also if this variable exists in the phers
package, it will be accessible without using the ::
.
Spacing
phecodes = merge(ICDs, ICDPhecodeMap,
by = c('ICD', 'flag'))[, .(person_ID, phecode)]
Imports, see previous comment.
See previous comment about ::
.
And I would prefer a line break after merge(
, to avoid excessive indentation.
Use |
in your i
argument instead of double-bracketing. Like this:
diseaseHPOMapSub = diseaseHPOMap[db_name == dbName | disease_ID %in% diseaseIDs]
More spacing
diseasePhecodeMap =merge(diseaseHPOMapSub,
HPOPhecodeMap[, !c('HPO_term_name')], by = 'term_ID')
diseasePhecodeMap = unique(diseasePhecodeMap[phecode != ''][, c('disease_ID',
'phecode')])
Like Jake is saying, look at some of your merge statements and any other line to see about being a little more tactical in your use of line breaks to clean things up.
Few things:
registerDoSEQ()
here instead.Fix up the spacing in general all around. To specifically call out a file though, look at the setup.R
script
Combine these into a single test function, and use the snapshot method instead of the way you are doing it in lines 5-7.
Noticed a few spacing issues in test-phers.R
.
Based on previous comment, when you move the map script functions into a single utils.R
script, update the test files accordingly.
For both of the map tests:
Make these into data files in the data folder instead of making them this way.
See above comment about registerDoParallel
.
As a naming convention, I now prefer get
as a function prefix instead of calc
.
This issue will track the 2nd code review for the phers package.