how to add a new column in colData in SummarizedExperiment
1
0
Entering edit mode
hwteng1971 • 0
@hwteng1971-15996
Last seen 3.1 years ago

Hi all:

I meet a problem :

I use TCGAbiolink to analyszed TCGA

query <- GDCquery(project = c("TCGA-COAD","TCGA-READ"), 

                  data.category = "Gene expression",

                  data.type = "Gene expression quantification",

                  experimental.strategy = "RNA-Seq",

                  platform = "Illumina HiSeq",

                  #sample.type = c("Primary solid Tumor",),

                  file.type = "results",

                  #barcode = v.barcode, 

                  legacy = TRUE

                  )

GDCdownload(query)

crc.naseq <- GDCprepare(query)# 會加入clinical data 組成 summarizedexperiment

 

if I want to merge a new column in colData, what should I Do??

I had try to do :

crc.naseq@colData@listData<-merge(crc.naseq@colData@listData,other.msi, by.x="patient",by.y="bcr_patient_barcode",all.x=TRUE)

but a problem noted.:

subset function fail due to this step

it seem due to the structure of  crc.naseq change and subset failure!

( in one month ago, it work)

Thanks lot 

summarizedexperiment tcgabiolinks • 2.2k views
ADD COMMENT
0
Entering edit mode

by Levi's concept

if I do a merge separated,  

then get  the new data as char 

then cbind ( old and new data)

then we can subset again 

But is any method can merge old colData and new colData

I thinks it is important because all like MS-SQL, this action is important 

or is any setter can use :merge?""

 

ADD REPLY
3
Entering edit mode
@levi-waldron-3429
Last seen 3 months ago
CUNY Graduate School of Public Health a…

Core Bioconductor classes like SummarizedExperiment are designed so you should not have to use @ to access slots directly, and users are encouraged instead to use the accessors / setters provided (discussion of why). I haven't tried to reproduce your steps, but here are a couple ways that appending columns to the colData of a SummarizedExperiment can be more simply done:

library(SummarizedExperiment)
example("SummarizedExperiment")
rse1$extracol <- 1:6
colData(rse1) <- cbind(colData(rse1), secondcol=7:12)
colData(rse1)
DataFrame with 6 rows and 3 columns
    Treatment  extracol secondcol
  <character> <integer> <integer>
A        ChIP         1         7
B       Input         2         8
C        ChIP         3         9
D       Input         4        10
E        ChIP         5        11
F       Input         6        12
ADD COMMENT
0
Entering edit mode

to dear Levi Waldron 

Thank you for helping.

this can work. but 

sometimes, We want to merge 2 set by some same ID  

for example, use want to cbind 2 col by same ID or patient barcode

what should we can do ???

sincerely need you expert

ADD REPLY
0
Entering edit mode

You can create your new colData any way you want, as long as 1) your replacement colData is still of class DataFrame, and 2) your replacement DataFrame still has rownames identical to the colnames of the SummarizedExperiment. Note you you could also construct a new SummarizedExperiment using the SummarizedExperiment() constructor function, which is more forgiving in that it tries to coerce the colData argument to a DataFrame (but still requires item #2 above).

ADD REPLY
0
Entering edit mode

thanks for comment

might I ask a small question?

how to retract the rowData, colData, assay and re-SummarizedExperiment();

I think this method might be the best method and easy to to after I reconstruct a new colData()

thanks lots

ADD REPLY
0
Entering edit mode

 

Hi,

I have done the above, but using the merge function. See this post: https://stackoverflow.com/questions/52853688/merge-column-to-summarizedexperiment-from-other-dataframe

How can I fix that I don't loose the colnames?

Thanks

ADD REPLY

Login before adding your answer.

Traffic: 243 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6