Search
Question: how to add a new column in colData in SummarizedExperiment
0
gravatar for hwteng1971
5 months ago by
hwteng19710
hwteng19710 wrote:

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 

ADD COMMENTlink modified 5 months ago • written 5 months ago by hwteng19710

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 REPLYlink written 5 months ago by hwteng19710
2
gravatar for Levi Waldron
5 months ago by
Levi Waldron790
CUNY Graduate School of Public Health and Health Policy, New York, NY
Levi Waldron790 wrote:

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 COMMENTlink modified 5 months ago • written 5 months ago by Levi Waldron790

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 REPLYlink written 5 months ago by hwteng19710

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 REPLYlink modified 5 months ago • written 5 months ago by Levi Waldron790

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 REPLYlink written 5 months ago by hwteng19710

 

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 REPLYlink modified 4 weeks ago • written 4 weeks ago by s.w.vanderlaan20
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.2.0
Traffic: 366 users visited in the last hour