Hi,
I have a RangedSummarizedExperiment
which looks like this:
class: RangedSummarizedExperiment
dim: 483731 485
metadata(4): creationDate author BBMRIomicsVersion note
assays(1): data
rownames(483731): cg01707559 cg02004872 ... ch.22.47579720R ch.22.48274842R
rowData names(10): addressA addressB ... probeEnd probeTarget
colnames(485): 200397860027_R01C01 200397860027_R02C02 ... 200556930046_R03C01 200556930046_R06C02
colData names(946): STUDY_NUMBER SampleID ... Basename ID
And I have a dataframe which looks like this:
STUDY_NUMBER UPID Testosterone Estradiol SHBG Gender
1 1 NA NA NA male
2 2 NA NA NA male
3 3 10.02 62 49.6 male
4 4 NA NA NA male
5 5 NA NA NA female
I would like to merge this table (n rows = 3662), based on STUDY_NUMBER
. So I used the following code:
colData(aems450k1.MvaluesQCIMPplaqueSE) <- merge(colData(aems450k1.MvaluesQCIMPplaqueSE), AEDB_Q1_20180223_sex, by = "STUDY_NUMBER", all.x = TRUE)
Which results in the following RangedSummarizedExperiment
object:
class: RangedSummarizedExperiment
dim: 483731 485
metadata(4): creationDate author BBMRIomicsVersion note
assays(1): data
rownames(483731): cg01707559 cg02004872 ... ch.22.47579720R ch.22.48274842R
rowData names(10): addressA addressB ... probeEnd probeTarget
colnames: NULL
colData names(952): STUDY_NUMBER SampleID ... Sex T_E2
You'll note that colnames
is now NULL. My question therefore:
How can I prevent this from happening?
My second question:
Could this be happening because the order (based on STUDY_NUMBER
) of the two dataframes are not the same?
In fact: Could this result in the colData being 'uncoupled' from the Assay data? Reason of I am thinking this, is because an analysis on a variable X in the dataset (not in the merged-data) results in a significant result. After merging (the variable X has not changed!), the exact same analysis is not significant anymore...
Many thanks,
Sander
I think the issue is that the
colData
gets a different order than theAssay
data, which should not happen. But if Isort =
to the merge command everything is just fine, and I can add the colnames later on. So:Which results in :
Which is the correct order in the
colnames
. While withoutsort =
, the order of colnames would be likecolnames(485): 9221198166_R06C02 9221198166_R06C01 ... 8918692001_R02C01 8918692001_R01C01
.Does this makes sense?