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

`colData<-` produces persistent warnings after reassigning the original column data back to `colData` slot #152

Closed ff98li closed 2 years ago

ff98li commented 2 years ago

Expected Behavior

No warnings

Current Behavior

After doing the following steps, warnings keep popping up whenever an TRE object or data.table gets called (so not just the object itself, but this behavior propagates to all other TRE objects and data.table)

Steps to Reproduce

data(nci_TRE_small)
tre_small <- copy(nci_TRE_small)
row_data <- rowData(tre_small) # export row data
rowData(tre_small) <- row_data # assign row data back to the tre object, no warnings in this step
col_data <- colData(tre_small) # export column data

Output

> colData(tre_small) <- col_data
warning messages from top-level task callback 'vsc.workspace'
Warning messages:
1: In `[.data.table`(x@colData, , -c(".colnames", "colKey")) :
  column(s) not removed because not found: [.colnames]
2: In `[.data.table`(x@colData, , -c(".colnames", "colKey")) :
  column(s) not removed because not found: [.colnames]
> tre_small
<TreatmentResponseExperiment> 
dim:  2368 10 
assays(3): sensitivity profiles assay_metadata 
rownames(2368): 2-Fluoro Ara-A:NA:6e-08:NA:1 2-Fluoro Ara-A:NA:6e-08:NA:28 ... vemurafenib2:Pemetrexed Disodium:5e-08:1e-06:1 vemurafenib2:Thioguanine|6-Thioguanine:5e-08:1e-05:1 
rowData(8): drug1id drug2id drug1dose ... NSC2 NSC1 row Key 
colnames(10):  
colData(6): cellid PANELNBR CELLNBR PANEL col Key .rownames 
metadata(1): experiment_metadata 
Warning messages:
1: In `[.data.table`(x@colData, , -c(".colnames", "colKey")) :
  column(s) not removed because not found: [.colnames]
2: In `[.data.table`(x@colData, , -c(".colnames", "colKey")) :
  column(s) not removed because not found: [.colnames]
3: In `[.data.table`(x@colData, , -c(".colnames", "colKey")) :
  column(s) not removed because not found: [.colnames]
4: In `[.data.table`(x@colData, , -c(".colnames", "colKey")) :
  column(s) not removed because not found: [.colnames]
5: In `[.data.table`(x@colData, , -c(".colnames", "colKey")) :
  column(s) not removed because not found: [.colnames]
warning messages from top-level task callback 'vsc.workspace'
Warning messages:
1: In `[.data.table`(x@colData, , -c(".colnames", "colKey")) :
  column(s) not removed because not found: [.colnames]
2: In `[.data.table`(x@colData, , -c(".colnames", "colKey")) :
  column(s) not removed because not found: [.colnames]
> colData(tre_small)
      cellid PANELNBR CELLNBR                      PANEL col Key .rownames
 1:    786-0        9      18               Renal Cancer       1     786-0
 2: CCRF-CEM        7       3                   Leukemia       2  CCRF-CEM
 3:   HCT-15        4      15               Colon Cancer       3    HCT-15
 4:   IGROV1        6      10             Ovarian Cancer       4    IGROV1
 5:     MCF7        5       1              Breast Cancer       5      MCF7
 6:  NCI-H23        1       1 Non-Small Cell Lung Cancer       6   NCI-H23
 7:  OVCAR-4        6       2             Ovarian Cancer       7   OVCAR-4
 8:   SF-268       12      14                 CNS Cancer       8    SF-268
 9:  SK-OV-3        6      11             Ovarian Cancer       9   SK-OV-3
10:    T-47D        5      14              Breast Cancer      10     T-47D
Warning message:
In `[.data.table`(x@colData, , -c(".colnames", "colKey")) :
  column(s) not removed because not found: [.colnames]
warning messages from top-level task callback 'vsc.workspace'
Warning messages:
1: In `[.data.table`(x@colData, , -c(".colnames", "colKey")) :
  column(s) not removed because not found: [.colnames]
2: In `[.data.table`(x@colData, , -c(".colnames", "colKey")) :
  column(s) not removed because not found: [.colnames]

Context (Environment)

nci_TRE_small is a TRE object subsetted by skipping every 27 row data observations and 6 column data observations.

Detailed Description

Notice that in the colData output of the object containing the column data assigned back to its original slot, we have .rownames, which is supposed to be .colnames. My simple guess is somewhere in the code for joining tables we miswrote .colnames as .rownames. The warnings will be gone after removing the object from the environment, i.e., rm(list = "tre_small").

ChristopherEeles commented 2 years ago

I fixed this but forgot to mention it in the commit.