hansenlab / minfi

Devel repository for minfi
58 stars 70 forks source link

SUGGESTION: More efficient code using matrixStats (>= 0.50.0) #34

Closed HenrikBengtsson closed 8 years ago

HenrikBengtsson commented 8 years ago

In matrixStats (>= 0.50.0), which is now on CRAN, we introduce support for subsetted calculations that are optimized both for speed and memory usage. There are now new arguments idxs, rows and cols for most functions which allow you to very easily make use of this.

For your package, I believe the following functions could gain from this:

$minfi$.getSex
[1] matrixStats::colMedians(CN[xIndex, ], na.rm = TRUE)
[2] matrixStats::colMedians(CN[yIndex, ], na.rm = TRUE)

$minfi$bgIntensitySwan
[1] matrixStats::colMedians(getGreen(rgSet)[getControlAddress(rgSet, controlType = "NEGATIVE"), ])
[2] redMed <- matrixStats::colMedians(getRed(rgSet)[getControlAddress(rgSet, controlType = "NEGATIVE"), ])

by updating to something like:

$minfi$.getSex
[1] matrixStats::colMedians(CN, rows = xIndex, na.rm = TRUE)
[2] matrixStats::colMedians(CN, rows = yIndex, na.rm = TRUE)

$minfi$bgIntensitySwan
[1] matrixStats::colMedians(getGreen(rgSet), rows = getControlAddress(rgSet, controlType = "NEGATIVE"))
[2] redMed <- matrixStats::colMedians(getRed(rgSet), rows = getControlAddress(rgSet, controlType = "NEGATIVE"))

and adding matrixStats (>= 0.50.0) to your DESCRIPTION file.

kasperdanielhansen commented 8 years ago

Thanks, I have integrated the suggestion.