bhklab / CoreGx

Shared code for both PharmacoGx and RadioGx
https://bhklab.github.io/CoreGx/
GNU General Public License v3.0
2 stars 3 forks source link

Subsetting a `TreamentResponseExperiment` corrupts referrential integrity #148

Closed ChristopherEeles closed 2 years ago

ChristopherEeles commented 2 years ago

After running: https://github.com/bhklab/pkg_scripts/blob/master/CoreGx/longtable_assayMap.R to create a tre.

Taking a subset breaks unit test in test-LongTable-accessors.R:75 if the object is subset first like:

stre <- subset(tre, drug1id %in% unique(drug1id)[1:5], cellid %in% unique(cellid)[1:5])

I suspect this is caused by inclusion of NA values in the assayIndex table, leading to the subset failing to drop assayIndex values where there are no observations.

ChristopherEeles commented 2 years ago

Error is occurring due to failure to drop rowKey or colKey values where no observations exist after sub-setting assays.

ChristopherEeles commented 2 years ago

Fix will be to determine the set of unique rowKeys and colKeys where there is an observation in at least one assay and subset the index to only those values before passing to .subsetByIndex in subset,LongTable-method.

ChristopherEeles commented 2 years ago

Not sure why my commit didn't close this? Maybe it needs to be merged to main first?