How to create a data set from object/data frame?

classic Classic list List threaded Threaded
13 messages Options
Reply | Threaded
Open this post in threaded view
|

How to create a data set from object/data frame?

Spencer Brackett
Hello,

  I am trying to create a data set from an object called ‘anno’ in my
environment. I’ve tried arguments like saveRDS(anno, file = “”) and
save(anno, file “.RData”) to save the object as a file to see if that will
work, but it seems for the particular procedure I am trying to carry out, I
need to transpose the object to a data set. Any ideas as to how I might do
this? For reference, my next step in manipulating the data contained in the
object is data(), which evidently does not work for reading in data frame
objects as data(“file/object name).

Best,

Spencer

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

Re: How to create a data set from object/data frame?

Sarah Goslee
Hi Spencer,

Your description doesn't make any sense to me. If anno is already an R
object, what are you trying to do with it?

data() is for loading datasets that come with packages; if your object
is already an R object in your environment, then there's no need for
it.

It sounds like you are possibly working through an example provided
elsewhere, that has sample data loaded with data(). If so, then you do
not need that step for your own data. You just need to import it into
R in the correct format.

If that doesn't help, then I think we need more information on what
you're trying to do.

Sarah

On Fri, Jul 19, 2019 at 10:18 AM Spencer Brackett
<[hidden email]> wrote:

>
> Hello,
>
>   I am trying to create a data set from an object called ‘anno’ in my
> environment. I’ve tried arguments like saveRDS(anno, file = “”) and
> save(anno, file “.RData”) to save the object as a file to see if that will
> work, but it seems for the particular procedure I am trying to carry out, I
> need to transpose the object to a data set. Any ideas as to how I might do
> this? For reference, my next step in manipulating the data contained in the
> object is data(), which evidently does not work for reading in data frame
> objects as data(“file/object name).
>
> Best,
>
> Spencer
>
>         [[alternative HTML version deleted]]
>
> ______________________________________________
> [hidden email] mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.



--
Sarah Goslee (she/her)
http://www.numberwright.com

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

Re: How to create a data set from object/data frame?

Spencer Brackett
Sarah,

  I am trying to extract phenoData (ie sample information) from the object
as part of a procedure to analyze my array for probe sets, which I realize
is under the BioConducter package Biobase and not relevant to this mailing
list.

  Yes the original procedure uses data from the Dilution dataset hosted in
the AffyBatch package affydata. Previous to this part of the procedure, a
dataset was create via..

  >fake.data <- matrix(rnorm(8*200), ncol=8)
##Then phenotype (sample) data was generated in this example through... ##

  sample.info <- data.frame( + spl=paste('A', 1:8, sep=''), +
stat=rep(c('cancer' , 'healthy'), each=4))

##Then a meta data.frame object was created to give more intelligible
labels##

> meta.info <- data.frame (labelDescription = + c('Sample Name' , 'Cancer
Status')) Then we put them all together: > pheno <-
new("AnnotatedDataFrame", + data = sample.info, + varMetadata = meta.info)

##Which was then aggregated together##

> pheno <- new("AnnotatedDataFrame", + data = sample.info, + varMetadata =
meta.info)

  >my.experiments <- new("ExpressionSet", + exprs=fake.data,
phenoData=pheno)
   > my.experiments
ExpressionSet (storageMode: lockedEnvironment) assayData: 200 features, 8
samples element names: exprs

##The following deals with further manipulating the phenoData##
phenoData
   sampleNames: 1, 2, ..., 8 (8 total) varLabels and varMetadata
description: spl: Sample Name stat: Cancer Status

featureData
 featureNames: 1, 2, ..., 200 (200 total) fvarLabels and fvarMetadata
description: none
experimentData:  use 'experimentData(object)'
Annotation:

##At this point is when the dataset 'Dilution was read in through
data(Dilution)

which was made an object of the AnnotatedDataFrame via

>phenoData(Dilution)

My apologies in advance as I know the above info. pertains to functions
carried out strictly through BioConducor, but is the only context I can
provide for what I am trying to do.

Best,

Spencer


On Fri, Jul 19, 2019 at 10:23 AM Sarah Goslee <[hidden email]>
wrote:

> Hi Spencer,
>
> Your description doesn't make any sense to me. If anno is already an R
> object, what are you trying to do with it?
>
> data() is for loading datasets that come with packages; if your object
> is already an R object in your environment, then there's no need for
> it.
>
> It sounds like you are possibly working through an example provided
> elsewhere, that has sample data loaded with data(). If so, then you do
> not need that step for your own data. You just need to import it into
> R in the correct format.
>
> If that doesn't help, then I think we need more information on what
> you're trying to do.
>
> Sarah
>
> On Fri, Jul 19, 2019 at 10:18 AM Spencer Brackett
> <[hidden email]> wrote:
> >
> > Hello,
> >
> >   I am trying to create a data set from an object called ‘anno’ in my
> > environment. I’ve tried arguments like saveRDS(anno, file = “”) and
> > save(anno, file “.RData”) to save the object as a file to see if that
> will
> > work, but it seems for the particular procedure I am trying to carry
> out, I
> > need to transpose the object to a data set. Any ideas as to how I might
> do
> > this? For reference, my next step in manipulating the data contained in
> the
> > object is data(), which evidently does not work for reading in data frame
> > objects as data(“file/object name).
> >
> > Best,
> >
> > Spencer
> >
> >         [[alternative HTML version deleted]]
> >
> > ______________________________________________
> > [hidden email] mailing list -- To UNSUBSCRIBE and more, see
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> > and provide commented, minimal, self-contained, reproducible code.
>
>
>
> --
> Sarah Goslee (she/her)
> http://www.numberwright.com
>

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

Re: How to create a data set from object/data frame?

Sarah Goslee
Right. If you have some equivalent to the Dilution dataset, then you
need to get it into R in the appropriate way for whatever data you
have.

data() is merely a way to get stored R data into your R session.
There's no reason you need to use data() rather than read.table() or
whatever is appropriate for the data you have available.

Or if you needed that exact dataset, data(Dilution) would get it into
your R session.

Do look at ?data if you haven't already.

Sarah

On Fri, Jul 19, 2019 at 10:46 AM Spencer Brackett
<[hidden email]> wrote:

>
> Sarah,
>
>   I am trying to extract phenoData (ie sample information) from the object as part of a procedure to analyze my array for probe sets, which I realize is under the BioConducter package Biobase and not relevant to this mailing list.
>
>   Yes the original procedure uses data from the Dilution dataset hosted in the AffyBatch package affydata. Previous to this part of the procedure, a dataset was create via..
>
>   >fake.data <- matrix(rnorm(8*200), ncol=8)
> ##Then phenotype (sample) data was generated in this example through... ##
>
>   sample.info <- data.frame( + spl=paste('A', 1:8, sep=''), + stat=rep(c('cancer' , 'healthy'), each=4))
>
> ##Then a meta data.frame object was created to give more intelligible labels##
>
> > meta.info <- data.frame (labelDescription = + c('Sample Name' , 'Cancer Status')) Then we put them all together: > pheno <- new("AnnotatedDataFrame", + data = sample.info, + varMetadata = meta.info)
>
> ##Which was then aggregated together##
>
> > pheno <- new("AnnotatedDataFrame", + data = sample.info, + varMetadata = meta.info)
>
>   >my.experiments <- new("ExpressionSet", + exprs=fake.data, phenoData=pheno)
>    > my.experiments
> ExpressionSet (storageMode: lockedEnvironment) assayData: 200 features, 8 samples element names: exprs
>
> ##The following deals with further manipulating the phenoData##
> phenoData
>    sampleNames: 1, 2, ..., 8 (8 total) varLabels and varMetadata description: spl: Sample Name stat: Cancer Status
>
> featureData
>  featureNames: 1, 2, ..., 200 (200 total) fvarLabels and fvarMetadata description: none
> experimentData:  use 'experimentData(object)'
> Annotation:
>
> ##At this point is when the dataset 'Dilution was read in through data(Dilution)
>
> which was made an object of the AnnotatedDataFrame via
>
> >phenoData(Dilution)
>
> My apologies in advance as I know the above info. pertains to functions carried out strictly through BioConducor, but is the only context I can provide for what I am trying to do.
>
> Best,
>
> Spencer
>
>
> On Fri, Jul 19, 2019 at 10:23 AM Sarah Goslee <[hidden email]> wrote:
>>
>> Hi Spencer,
>>
>> Your description doesn't make any sense to me. If anno is already an R
>> object, what are you trying to do with it?
>>
>> data() is for loading datasets that come with packages; if your object
>> is already an R object in your environment, then there's no need for
>> it.
>>
>> It sounds like you are possibly working through an example provided
>> elsewhere, that has sample data loaded with data(). If so, then you do
>> not need that step for your own data. You just need to import it into
>> R in the correct format.
>>
>> If that doesn't help, then I think we need more information on what
>> you're trying to do.
>>
>> Sarah
>>
>> On Fri, Jul 19, 2019 at 10:18 AM Spencer Brackett
>> <[hidden email]> wrote:
>> >
>> > Hello,
>> >
>> >   I am trying to create a data set from an object called ‘anno’ in my
>> > environment. I’ve tried arguments like saveRDS(anno, file = “”) and
>> > save(anno, file “.RData”) to save the object as a file to see if that will
>> > work, but it seems for the particular procedure I am trying to carry out, I
>> > need to transpose the object to a data set. Any ideas as to how I might do
>> > this? For reference, my next step in manipulating the data contained in the
>> > object is data(), which evidently does not work for reading in data frame
>> > objects as data(“file/object name).
>> >
>> > Best,
>> >
>> > Spencer
>> >\

--
Sarah Goslee (she/her)
http://www.numberwright.com

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

Re: How to create a data set from object/data frame?

Spencer Brackett
In reply to this post by Spencer Brackett
Sarah,

Thank you for the reference to ?data. Upon further research into the
matter, I think I can provide a simpler explanation than the one previously
provided. I am trying to reproduce the following code with an object --
'anno' -- in my data frame/environment.

  >fake.data <- matrix(rnorm(8*200), ncol=8)

I found the number of columns with >ncol(anno)  , which is 3

How do I find rnorm when I don't have the data table (saved as the 'anno'
object) mean or standard dev. ?

I will try reading in the data object through read.table() now, though
won't that just print the data or a subset thereof into my R console?



On Fri, Jul 19, 2019 at 10:46 AM Spencer Brackett <
[hidden email]> wrote:

> Sarah,
>
>   I am trying to extract phenoData (ie sample information) from the object
> as part of a procedure to analyze my array for probe sets, which I realize
> is under the BioConducter package Biobase and not relevant to this mailing
> list.
>
>   Yes the original procedure uses data from the Dilution dataset hosted in
> the AffyBatch package affydata. Previous to this part of the procedure, a
> dataset was create via..
>
>   >fake.data <- matrix(rnorm(8*200), ncol=8)
> ##Then phenotype (sample) data was generated in this example through... ##
>
>   sample.info <- data.frame( + spl=paste('A', 1:8, sep=''), +
> stat=rep(c('cancer' , 'healthy'), each=4))
>
> ##Then a meta data.frame object was created to give more intelligible
> labels##
>
> > meta.info <- data.frame (labelDescription = + c('Sample Name' , 'Cancer
> Status')) Then we put them all together: > pheno <-
> new("AnnotatedDataFrame", + data = sample.info, + varMetadata = meta.info
> )
>
> ##Which was then aggregated together##
>
> > pheno <- new("AnnotatedDataFrame", + data = sample.info, + varMetadata
> = meta.info)
>
>   >my.experiments <- new("ExpressionSet", + exprs=fake.data,
> phenoData=pheno)
>    > my.experiments
> ExpressionSet (storageMode: lockedEnvironment) assayData: 200 features, 8
> samples element names: exprs
>
> ##The following deals with further manipulating the phenoData##
> phenoData
>    sampleNames: 1, 2, ..., 8 (8 total) varLabels and varMetadata
> description: spl: Sample Name stat: Cancer Status
>
> featureData
>  featureNames: 1, 2, ..., 200 (200 total) fvarLabels and fvarMetadata
> description: none
> experimentData:  use 'experimentData(object)'
> Annotation:
>
> ##At this point is when the dataset 'Dilution was read in through
> data(Dilution)
>
> which was made an object of the AnnotatedDataFrame via
>
> >phenoData(Dilution)
>
> My apologies in advance as I know the above info. pertains to functions
> carried out strictly through BioConducor, but is the only context I can
> provide for what I am trying to do.
>
> Best,
>
> Spencer
>
>
> On Fri, Jul 19, 2019 at 10:23 AM Sarah Goslee <[hidden email]>
> wrote:
>
>> Hi Spencer,
>>
>> Your description doesn't make any sense to me. If anno is already an R
>> object, what are you trying to do with it?
>>
>> data() is for loading datasets that come with packages; if your object
>> is already an R object in your environment, then there's no need for
>> it.
>>
>> It sounds like you are possibly working through an example provided
>> elsewhere, that has sample data loaded with data(). If so, then you do
>> not need that step for your own data. You just need to import it into
>> R in the correct format.
>>
>> If that doesn't help, then I think we need more information on what
>> you're trying to do.
>>
>> Sarah
>>
>> On Fri, Jul 19, 2019 at 10:18 AM Spencer Brackett
>> <[hidden email]> wrote:
>> >
>> > Hello,
>> >
>> >   I am trying to create a data set from an object called ‘anno’ in my
>> > environment. I’ve tried arguments like saveRDS(anno, file = “”) and
>> > save(anno, file “.RData”) to save the object as a file to see if that
>> will
>> > work, but it seems for the particular procedure I am trying to carry
>> out, I
>> > need to transpose the object to a data set. Any ideas as to how I might
>> do
>> > this? For reference, my next step in manipulating the data contained in
>> the
>> > object is data(), which evidently does not work for reading in data
>> frame
>> > objects as data(“file/object name).
>> >
>> > Best,
>> >
>> > Spencer
>> >
>> >         [[alternative HTML version deleted]]
>> >
>> > ______________________________________________
>> > [hidden email] mailing list -- To UNSUBSCRIBE and more, see
>> > https://stat.ethz.ch/mailman/listinfo/r-help
>> > PLEASE do read the posting guide
>> http://www.R-project.org/posting-guide.html
>> > and provide commented, minimal, self-contained, reproducible code.
>>
>>
>>
>> --
>> Sarah Goslee (she/her)
>> http://www.numberwright.com
>>
>

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

Re: How to create a data set from object/data frame?

Sarah Goslee
You don't need fake.data or rnorm(), which was used to generate the fake data.

You need to use your real data for the analysis, not anything randomly
generated for example purposes, or anything included with a package
for example purposes.

In both cases, those are just worked examples.You need to analyze your
own comparable data.

Sarah

On Fri, Jul 19, 2019 at 12:17 PM Spencer Brackett
<[hidden email]> wrote:

>
> Sarah,
>
> Thank you for the reference to ?data. Upon further research into the matter, I think I can provide a simpler explanation than the one previously provided. I am trying to reproduce the following code with an object -- 'anno' -- in my data frame/environment.
>
>   >fake.data <- matrix(rnorm(8*200), ncol=8)
>
> I found the number of columns with >ncol(anno)  , which is 3
>
> How do I find rnorm when I don't have the data table (saved as the 'anno' object) mean or standard dev. ?
>
> I will try reading in the data object through read.table() now, though won't that just print the data or a subset thereof into my R console?
>
>
>
> On Fri, Jul 19, 2019 at 10:46 AM Spencer Brackett <[hidden email]> wrote:
>>
>> Sarah,
>>
>>   I am trying to extract phenoData (ie sample information) from the object as part of a procedure to analyze my array for probe sets, which I realize is under the BioConducter package Biobase and not relevant to this mailing list.
>>
>>   Yes the original procedure uses data from the Dilution dataset hosted in the AffyBatch package affydata. Previous to this part of the procedure, a dataset was create via..
>>
>>   >fake.data <- matrix(rnorm(8*200), ncol=8)
>> ##Then phenotype (sample) data was generated in this example through... ##
>>
>>   sample.info <- data.frame( + spl=paste('A', 1:8, sep=''), + stat=rep(c('cancer' , 'healthy'), each=4))
>>
>> ##Then a meta data.frame object was created to give more intelligible labels##
>>
>> > meta.info <- data.frame (labelDescription = + c('Sample Name' , 'Cancer Status')) Then we put them all together: > pheno <- new("AnnotatedDataFrame", + data = sample.info, + varMetadata = meta.info)
>>
>> ##Which was then aggregated together##
>>
>> > pheno <- new("AnnotatedDataFrame", + data = sample.info, + varMetadata = meta.info)
>>
>>   >my.experiments <- new("ExpressionSet", + exprs=fake.data, phenoData=pheno)
>>    > my.experiments
>> ExpressionSet (storageMode: lockedEnvironment) assayData: 200 features, 8 samples element names: exprs
>>
>> ##The following deals with further manipulating the phenoData##
>> phenoData
>>    sampleNames: 1, 2, ..., 8 (8 total) varLabels and varMetadata description: spl: Sample Name stat: Cancer Status
>>
>> featureData
>>  featureNames: 1, 2, ..., 200 (200 total) fvarLabels and fvarMetadata description: none
>> experimentData:  use 'experimentData(object)'
>> Annotation:
>>
>> ##At this point is when the dataset 'Dilution was read in through data(Dilution)
>>
>> which was made an object of the AnnotatedDataFrame via
>>
>> >phenoData(Dilution)
>>
>> My apologies in advance as I know the above info. pertains to functions carried out strictly through BioConducor, but is the only context I can provide for what I am trying to do.
>>
>> Best,
>>
>> Spencer
>>
>>
>> On Fri, Jul 19, 2019 at 10:23 AM Sarah Goslee <[hidden email]> wrote:
>>>
>>> Hi Spencer,
>>>
>>> Your description doesn't make any sense to me. If anno is already an R
>>> object, what are you trying to do with it?
>>>
>>> data() is for loading datasets that come with packages; if your object
>>> is already an R object in your environment, then there's no need for
>>> it.
>>>
>>> It sounds like you are possibly working through an example provided
>>> elsewhere, that has sample data loaded with data(). If so, then you do
>>> not need that step for your own data. You just need to import it into
>>> R in the correct format.
>>>
>>> If that doesn't help, then I think we need more information on what
>>> you're trying to do.
>>>
>>> Sarah
>>>
>>> On Fri, Jul 19, 2019 at 10:18 AM Spencer Brackett
>>> <[hidden email]> wrote:
>>> >
>>> > Hello,
>>> >
>>> >   I am trying to create a data set from an object called ‘anno’ in my
>>> > environment. I’ve tried arguments like saveRDS(anno, file = “”) and
>>> > save(anno, file “.RData”) to save the object as a file to see if that will
>>> > work, but it seems for the particular procedure I am trying to carry out, I
>>> > need to transpose the object to a data set. Any ideas as to how I might do
>>> > this? For reference, my next step in manipulating the data contained in the
>>> > object is data(), which evidently does not work for reading in data frame
>>> > objects as data(“file/object name).
>>> >
>>> > Best,
>>> >
>>> > Spencer
>>> >
>>> >         [[alternative HTML version deleted]]
>>> >
>>> > ______________________________________________
>>> > [hidden email] mailing list -- To UNSUBSCRIBE and more, see
>>> > https://stat.ethz.ch/mailman/listinfo/r-help
>>> > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
>>> > and provide commented, minimal, self-contained, reproducible code.
>>>
>>>

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

Re: How to create a data set from object/data frame?

Spencer Brackett
Okay. I am a little confused as to how to proceed with that. The next part
of the procedure as seen below appears to be substituting information from
this fake data set into the following arguments in order to

 sample.info <- data.frame( + spl=paste('A', 1:8, sep=''), +
stat=rep(c('cancer' , 'healthy'), each=4))

##Then a meta data.frame object was created to give more intelligible
labels##

> meta.info <- data.frame (labelDescription = + c('Sample Name' , 'Cancer
Status')) Then we put them all together: > pheno <-
new("AnnotatedDataFrame", + data = sample.info, + varMetadata = meta.info)

##Which was then aggregated together##

> pheno <- new("AnnotatedDataFrame", + data = sample.info, + varMetadata =
meta.info)

  >my.experiments <- new("ExpressionSet", + exprs=fake.data,
phenoData=pheno)
   > my.experiments
ExpressionSet (storageMode: lockedEnvironment) assayData: 200 features, 8
samples element names: exprs

##The following deals with further manipulating the phenoData##
phenoData
   sampleNames: 1, 2, ..., 8 (8 total) varLabels and varMetadata
description: spl: Sample Name stat: Cancer Status

featureData
   featureNames: 1, 2, ..., 200 (200 total)
   fvarLabels and fvarMetadata description: none
experimentData:  use 'experimentData(object)'
Annotation:

##At this point is when the dataset 'Dilution' was read in through
data(Dilution)

 >library(affydata)
 > data(Dilution)

which was made an object of the AnnotatedDataFrame via
>Dilution
>phenoData(Dilution)
>pData(Dilution)

##To access the probesets###

 > geneNames(Dilution)[1:3] [1] "100_g_at" "1000_at" "1001_at"
> random.affyid <- sample(geneNames(Dilution), 1)
> # random.affyid <- '34803_at'
> ps <- probeset(Dilution, random.affyid)[[1]]

How would I substitute in my anno object to achieve this?

On Fri, Jul 19, 2019 at 1:47 PM Spencer Brackett <
[hidden email]> wrote:

> Okay. I am a little confused as to how to proceed with that. The next part
> of the procedure as seen below appears to be substituting information from
> this fake data set into the following arguments in order to
>
>  sample.info <- data.frame( + spl=paste('A', 1:8, sep=''), +
> stat=rep(c('cancer' , 'healthy'), each=4))
>
> ##Then a meta data.frame object was created to give more intelligible
> labels##
>
> > meta.info <- data.frame (labelDescription = + c('Sample Name' , 'Cancer
> Status')) Then we put them all together: > pheno <-
> new("AnnotatedDataFrame", + data = sample.info, + varMetadata = meta.info
> )
>
> ##Which was then aggregated together##
>
> > pheno <- new("AnnotatedDataFrame", + data = sample.info, + varMetadata
> = meta.info)
>
>   >my.experiments <- new("ExpressionSet", + exprs=fake.data,
> phenoData=pheno)
>    > my.experiments
> ExpressionSet (storageMode: lockedEnvironment) assayData: 200 features, 8
> samples element names: exprs
>
> ##The following deals with further manipulating the phenoData##
> phenoData
>    sampleNames: 1, 2, ..., 8 (8 total) varLabels and varMetadata
> description: spl: Sample Name stat: Cancer Status
>
> featureData
>    featureNames: 1, 2, ..., 200 (200 total)
>    fvarLabels and fvarMetadata description: none
> experimentData:  use 'experimentData(object)'
> Annotation:
>
> ##At this point is when the dataset 'Dilution' was read in through
> data(Dilution)
>
>  >library(affydata)
>  > data(Dilution)
>
> which was made an object of the AnnotatedDataFrame via
> >Dilution
> >phenoData(Dilution)
> >pData(Dilution)
>
> ##To access the probesets###
>
>  > geneNames(Dilution)[1:3] [1] "100_g_at" "1000_at" "1001_at"
> > random.affyid <- sample(geneNames(Dilution), 1)
> > # random.affyid <- '34803_at'
> > ps <- probeset(Dilution, random.affyid)[[1]]
>
> How would I substitute in my anno object to achieve this?
>
>
>
>
> On Fri, Jul 19, 2019 at 1:32 PM Sarah Goslee <[hidden email]>
> wrote:
>
>> You don't need fake.data or rnorm(), which was used to generate the fake
>> data.
>>
>> You need to use your real data for the analysis, not anything randomly
>> generated for example purposes, or anything included with a package
>> for example purposes.
>>
>> In both cases, those are just worked examples.You need to analyze your
>> own comparable data.
>>
>> Sarah
>>
>> On Fri, Jul 19, 2019 at 12:17 PM Spencer Brackett
>> <[hidden email]> wrote:
>> >
>> > Sarah,
>> >
>> > Thank you for the reference to ?data. Upon further research into the
>> matter, I think I can provide a simpler explanation than the one previously
>> provided. I am trying to reproduce the following code with an object --
>> 'anno' -- in my data frame/environment.
>> >
>> >   >fake.data <- matrix(rnorm(8*200), ncol=8)
>> >
>> > I found the number of columns with >ncol(anno)  , which is 3
>> >
>> > How do I find rnorm when I don't have the data table (saved as the
>> 'anno' object) mean or standard dev. ?
>> >
>> > I will try reading in the data object through read.table() now, though
>> won't that just print the data or a subset thereof into my R console?
>> >
>> >
>> >
>> > On Fri, Jul 19, 2019 at 10:46 AM Spencer Brackett <
>> [hidden email]> wrote:
>> >>
>> >> Sarah,
>> >>
>> >>   I am trying to extract phenoData (ie sample information) from the
>> object as part of a procedure to analyze my array for probe sets, which I
>> realize is under the BioConducter package Biobase and not relevant to this
>> mailing list.
>> >>
>> >>   Yes the original procedure uses data from the Dilution dataset
>> hosted in the AffyBatch package affydata. Previous to this part of the
>> procedure, a dataset was create via..
>> >>
>> >>   >fake.data <- matrix(rnorm(8*200), ncol=8)
>> >> ##Then phenotype (sample) data was generated in this example
>> through... ##
>> >>
>> >>   sample.info <- data.frame( + spl=paste('A', 1:8, sep=''), +
>> stat=rep(c('cancer' , 'healthy'), each=4))
>> >>
>> >> ##Then a meta data.frame object was created to give more intelligible
>> labels##
>> >>
>> >> > meta.info <- data.frame (labelDescription = + c('Sample Name' ,
>> 'Cancer Status')) Then we put them all together: > pheno <-
>> new("AnnotatedDataFrame", + data = sample.info, + varMetadata = meta.info
>> )
>> >>
>> >> ##Which was then aggregated together##
>> >>
>> >> > pheno <- new("AnnotatedDataFrame", + data = sample.info, +
>> varMetadata = meta.info)
>> >>
>> >>   >my.experiments <- new("ExpressionSet", + exprs=fake.data,
>> phenoData=pheno)
>> >>    > my.experiments
>> >> ExpressionSet (storageMode: lockedEnvironment) assayData: 200
>> features, 8 samples element names: exprs
>> >>
>> >> ##The following deals with further manipulating the phenoData##
>> >> phenoData
>> >>    sampleNames: 1, 2, ..., 8 (8 total) varLabels and varMetadata
>> description: spl: Sample Name stat: Cancer Status
>> >>
>> >> featureData
>> >>  featureNames: 1, 2, ..., 200 (200 total) fvarLabels and fvarMetadata
>> description: none
>> >> experimentData:  use 'experimentData(object)'
>> >> Annotation:
>> >>
>> >> ##At this point is when the dataset 'Dilution was read in through
>> data(Dilution)
>> >>
>> >> which was made an object of the AnnotatedDataFrame via
>> >>
>> >> >phenoData(Dilution)
>> >>
>> >> My apologies in advance as I know the above info. pertains to
>> functions carried out strictly through BioConducor, but is the only context
>> I can provide for what I am trying to do.
>> >>
>> >> Best,
>> >>
>> >> Spencer
>> >>
>> >>
>> >> On Fri, Jul 19, 2019 at 10:23 AM Sarah Goslee <[hidden email]>
>> wrote:
>> >>>
>> >>> Hi Spencer,
>> >>>
>> >>> Your description doesn't make any sense to me. If anno is already an R
>> >>> object, what are you trying to do with it?
>> >>>
>> >>> data() is for loading datasets that come with packages; if your object
>> >>> is already an R object in your environment, then there's no need for
>> >>> it.
>> >>>
>> >>> It sounds like you are possibly working through an example provided
>> >>> elsewhere, that has sample data loaded with data(). If so, then you do
>> >>> not need that step for your own data. You just need to import it into
>> >>> R in the correct format.
>> >>>
>> >>> If that doesn't help, then I think we need more information on what
>> >>> you're trying to do.
>> >>>
>> >>> Sarah
>> >>>
>> >>> On Fri, Jul 19, 2019 at 10:18 AM Spencer Brackett
>> >>> <[hidden email]> wrote:
>> >>> >
>> >>> > Hello,
>> >>> >
>> >>> >   I am trying to create a data set from an object called ‘anno’ in
>> my
>> >>> > environment. I’ve tried arguments like saveRDS(anno, file = “”) and
>> >>> > save(anno, file “.RData”) to save the object as a file to see if
>> that will
>> >>> > work, but it seems for the particular procedure I am trying to
>> carry out, I
>> >>> > need to transpose the object to a data set. Any ideas as to how I
>> might do
>> >>> > this? For reference, my next step in manipulating the data
>> contained in the
>> >>> > object is data(), which evidently does not work for reading in data
>> frame
>> >>> > objects as data(“file/object name).
>> >>> >
>> >>> > Best,
>> >>> >
>> >>> > Spencer
>> >>> >
>> >>> >         [[alternative HTML version deleted]]
>> >>> >
>> >>> > ______________________________________________
>> >>> > [hidden email] mailing list -- To UNSUBSCRIBE and more, see
>> >>> > https://stat.ethz.ch/mailman/listinfo/r-help
>> >>> > PLEASE do read the posting guide
>> http://www.R-project.org/posting-guide.html
>> >>> > and provide commented, minimal, self-contained, reproducible code.
>> >>>
>> >>>
>>
>

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

Re: How to create a data set from object/data frame?

Spencer Brackett
In reply to this post by Sarah Goslee
Sarah,

Okay. I am a little confused about how to proceed. How do I substitute my
anno object for the Dilution dataset, when in these following lines of the
code, as it appears that info from the fake dataset was extracted.. ?


 sample.info <- data.frame( + spl=paste('A', 1:8, sep=''), +
stat=rep(c('cancer' , 'healthy'), each=4))
>>
>> ##Then a meta data.frame object was created to give more intelligible
labels##
>>
>> > meta.info <- data.frame (labelDescription = + c('Sample Name' ,
'Cancer Status')) Then we put them all together: > pheno <-
new("AnnotatedDataFrame", + data = sample.info, + varMetadata = meta.info)
>>
>> ##Which was then aggregated together##
>>
>> > pheno <- new("AnnotatedDataFrame", + data = sample.info, + varMetadata
= meta.info)
>>
>>   >my.experiments <- new("ExpressionSet", + exprs=fake.data,
phenoData=pheno)
>>    > my.experiments
>> ExpressionSet (storageMode: lockedEnvironment) assayData: 200 features,
8 samples element names: exprs
>>
>> ##The following deals with further manipulating the phenoData##
>> phenoData
>>    sampleNames: 1, 2, ..., 8 (8 total) varLabels and varMetadata
description: spl: Sample Name stat: Cancer Status
>>
>> featureData
>>  featureNames: 1, 2, ..., 200 (200 total) fvarLabels and fvarMetadata
description: none
>> experimentData:  use 'experimentData(object)'
>> Annotation:
>>
>> ##At this point is when the dataset 'Dilution was read in through
data(Dilution)
>>
>> which was made an object of the AnnotatedDataFrame via
>>
>> >phenoData(Dilution)


On Fri, Jul 19, 2019 at 1:32 PM Sarah Goslee <[hidden email]> wrote:

> You don't need fake.data or rnorm(), which was used to generate the fake
> data.
>
> You need to use your real data for the analysis, not anything randomly
> generated for example purposes, or anything included with a package
> for example purposes.
>
> In both cases, those are just worked examples.You need to analyze your
> own comparable data.
>
> Sarah
>
> On Fri, Jul 19, 2019 at 12:17 PM Spencer Brackett
> <[hidden email]> wrote:
> >
> > Sarah,
> >
> > Thank you for the reference to ?data. Upon further research into the
> matter, I think I can provide a simpler explanation than the one previously
> provided. I am trying to reproduce the following code with an object --
> 'anno' -- in my data frame/environment.
> >
> >   >fake.data <- matrix(rnorm(8*200), ncol=8)
> >
> > I found the number of columns with >ncol(anno)  , which is 3
> >
> > How do I find rnorm when I don't have the data table (saved as the
> 'anno' object) mean or standard dev. ?
> >
> > I will try reading in the data object through read.table() now, though
> won't that just print the data or a subset thereof into my R console?
> >
> >
> >
> > On Fri, Jul 19, 2019 at 10:46 AM Spencer Brackett <
> [hidden email]> wrote:
> >>
> >> Sarah,
> >>
> >>   I am trying to extract phenoData (ie sample information) from the
> object as part of a procedure to analyze my array for probe sets, which I
> realize is under the BioConducter package Biobase and not relevant to this
> mailing list.
> >>
> >>   Yes the original procedure uses data from the Dilution dataset hosted
> in the AffyBatch package affydata. Previous to this part of the procedure,
> a dataset was create via..
> >>
> >>   >fake.data <- matrix(rnorm(8*200), ncol=8)
> >> ##Then phenotype (sample) data was generated in this example through...
> ##
> >>
> >>   sample.info <- data.frame( + spl=paste('A', 1:8, sep=''), +
> stat=rep(c('cancer' , 'healthy'), each=4))
> >>
> >> ##Then a meta data.frame object was created to give more intelligible
> labels##
> >>
> >> > meta.info <- data.frame (labelDescription = + c('Sample Name' ,
> 'Cancer Status')) Then we put them all together: > pheno <-
> new("AnnotatedDataFrame", + data = sample.info, + varMetadata = meta.info)
> >>
> >> ##Which was then aggregated together##
> >>
> >> > pheno <- new("AnnotatedDataFrame", + data = sample.info, +
> varMetadata = meta.info)
> >>
> >>   >my.experiments <- new("ExpressionSet", + exprs=fake.data,
> phenoData=pheno)
> >>    > my.experiments
> >> ExpressionSet (storageMode: lockedEnvironment) assayData: 200 features,
> 8 samples element names: exprs
> >>
> >> ##The following deals with further manipulating the phenoData##
> >> phenoData
> >>    sampleNames: 1, 2, ..., 8 (8 total) varLabels and varMetadata
> description: spl: Sample Name stat: Cancer Status
> >>
> >> featureData
> >>  featureNames: 1, 2, ..., 200 (200 total) fvarLabels and fvarMetadata
> description: none
> >> experimentData:  use 'experimentData(object)'
> >> Annotation:
> >>
> >> ##At this point is when the dataset 'Dilution was read in through
> data(Dilution)
> >>
> >> which was made an object of the AnnotatedDataFrame via
> >>
> >> >phenoData(Dilution)
> >>
> >> My apologies in advance as I know the above info. pertains to functions
> carried out strictly through BioConducor, but is the only context I can
> provide for what I am trying to do.
> >>
> >> Best,
> >>
> >> Spencer
> >>
> >>
> >> On Fri, Jul 19, 2019 at 10:23 AM Sarah Goslee <[hidden email]>
> wrote:
> >>>
> >>> Hi Spencer,
> >>>
> >>> Your description doesn't make any sense to me. If anno is already an R
> >>> object, what are you trying to do with it?
> >>>
> >>> data() is for loading datasets that come with packages; if your object
> >>> is already an R object in your environment, then there's no need for
> >>> it.
> >>>
> >>> It sounds like you are possibly working through an example provided
> >>> elsewhere, that has sample data loaded with data(). If so, then you do
> >>> not need that step for your own data. You just need to import it into
> >>> R in the correct format.
> >>>
> >>> If that doesn't help, then I think we need more information on what
> >>> you're trying to do.
> >>>
> >>> Sarah
> >>>
> >>> On Fri, Jul 19, 2019 at 10:18 AM Spencer Brackett
> >>> <[hidden email]> wrote:
> >>> >
> >>> > Hello,
> >>> >
> >>> >   I am trying to create a data set from an object called ‘anno’ in my
> >>> > environment. I’ve tried arguments like saveRDS(anno, file = “”) and
> >>> > save(anno, file “.RData”) to save the object as a file to see if
> that will
> >>> > work, but it seems for the particular procedure I am trying to carry
> out, I
> >>> > need to transpose the object to a data set. Any ideas as to how I
> might do
> >>> > this? For reference, my next step in manipulating the data contained
> in the
> >>> > object is data(), which evidently does not work for reading in data
> frame
> >>> > objects as data(“file/object name).
> >>> >
> >>> > Best,
> >>> >
> >>> > Spencer
> >>> >
> >>> >         [[alternative HTML version deleted]]
> >>> >
> >>> > ______________________________________________
> >>> > [hidden email] mailing list -- To UNSUBSCRIBE and more, see
> >>> > https://stat.ethz.ch/mailman/listinfo/r-help
> >>> > PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> >>> > and provide commented, minimal, self-contained, reproducible code.
> >>>
> >>>
>

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

Re: How to create a data set from object/data frame?

Sarah Goslee
In reply to this post by Sarah Goslee
Okay, at this point I have three suggestions, because you're clearly
not yet understanding the R workflow.

1. Read at least the Intro to R manual.
https://cran.r-project.org/doc/manuals/R-intro.pdf
2. Go through your sample code carefully, step by step, using
functions like str() and head() to look at the R objects produced at
each step, using ? to investigate functions you aren't familiar with,
and thinking as you go how those R objects do and don't resemble the
data you have.
3. If 1 and 2 don't help, you need to consult with your advisor,
mentor, or if there's nobody local to you that can help, the author of
the sample code you're using.

I don't have your sample code, don't have your data, am not familiar
with the specific functions you are using, and don't have time to
become familiar. You need to both improve your R understanding and
seek out guidance, ideally from someone whose job it is to help you.

Best,
Sarah

On Fri, Jul 19, 2019 at 1:47 PM Spencer Brackett
<[hidden email]> wrote:

>
> Okay. I am a little confused as to how to proceed with that. The next part of the procedure as seen below appears to be substituting information from this fake data set into the following arguments in order to
>
>  sample.info <- data.frame( + spl=paste('A', 1:8, sep=''), + stat=rep(c('cancer' , 'healthy'), each=4))
>
> ##Then a meta data.frame object was created to give more intelligible labels##
>
> > meta.info <- data.frame (labelDescription = + c('Sample Name' , 'Cancer Status')) Then we put them all together: > pheno <- new("AnnotatedDataFrame", + data = sample.info, + varMetadata = meta.info)
>
> ##Which was then aggregated together##
>
> > pheno <- new("AnnotatedDataFrame", + data = sample.info, + varMetadata = meta.info)
>
>   >my.experiments <- new("ExpressionSet", + exprs=fake.data, phenoData=pheno)
>    > my.experiments
> ExpressionSet (storageMode: lockedEnvironment) assayData: 200 features, 8 samples element names: exprs
>
> ##The following deals with further manipulating the phenoData##
> phenoData
>    sampleNames: 1, 2, ..., 8 (8 total) varLabels and varMetadata description: spl: Sample Name stat: Cancer Status
>
> featureData
>    featureNames: 1, 2, ..., 200 (200 total)
>    fvarLabels and fvarMetadata description: none
> experimentData:  use 'experimentData(object)'
> Annotation:
>
> ##At this point is when the dataset 'Dilution' was read in through data(Dilution)
>
>  >library(affydata)
>  > data(Dilution)
>
> which was made an object of the AnnotatedDataFrame via
> >Dilution
> >phenoData(Dilution)
> >pData(Dilution)
>
> ##To access the probesets###
>
>  > geneNames(Dilution)[1:3] [1] "100_g_at" "1000_at" "1001_at"
> > random.affyid <- sample(geneNames(Dilution), 1)
> > # random.affyid <- '34803_at'
> > ps <- probeset(Dilution, random.affyid)[[1]]
>
> How would I substitute in my anno object to achieve this?
>
>
>
>
> On Fri, Jul 19, 2019 at 1:32 PM Sarah Goslee <[hidden email]> wrote:
>>
>> You don't need fake.data or rnorm(), which was used to generate the fake data.
>>
>> You need to use your real data for the analysis, not anything randomly
>> generated for example purposes, or anything included with a package
>> for example purposes.
>>
>> In both cases, those are just worked examples.You need to analyze your
>> own comparable data.
>>
>> Sarah
>>
>> On Fri, Jul 19, 2019 at 12:17 PM Spencer Brackett
>> <[hidden email]> wrote:
>> >
>> > Sarah,
>> >
>> > Thank you for the reference to ?data. Upon further research into the matter, I think I can provide a simpler explanation than the one previously provided. I am trying to reproduce the following code with an object -- 'anno' -- in my data frame/environment.
>> >
>> >   >fake.data <- matrix(rnorm(8*200), ncol=8)
>> >
>> > I found the number of columns with >ncol(anno)  , which is 3
>> >
>> > How do I find rnorm when I don't have the data table (saved as the 'anno' object) mean or standard dev. ?
>> >
>> > I will try reading in the data object through read.table() now, though won't that just print the data or a subset thereof into my R console?
>> >
>> >
>> >
>> > On Fri, Jul 19, 2019 at 10:46 AM Spencer Brackett <[hidden email]> wrote:
>> >>
>> >> Sarah,
>> >>
>> >>   I am trying to extract phenoData (ie sample information) from the object as part of a procedure to analyze my array for probe sets, which I realize is under the BioConducter package Biobase and not relevant to this mailing list.
>> >>
>> >>   Yes the original procedure uses data from the Dilution dataset hosted in the AffyBatch package affydata. Previous to this part of the procedure, a dataset was create via..
>> >>
>> >>   >fake.data <- matrix(rnorm(8*200), ncol=8)
>> >> ##Then phenotype (sample) data was generated in this example through... ##
>> >>
>> >>   sample.info <- data.frame( + spl=paste('A', 1:8, sep=''), + stat=rep(c('cancer' , 'healthy'), each=4))
>> >>
>> >> ##Then a meta data.frame object was created to give more intelligible labels##
>> >>
>> >> > meta.info <- data.frame (labelDescription = + c('Sample Name' , 'Cancer Status')) Then we put them all together: > pheno <- new("AnnotatedDataFrame", + data = sample.info, + varMetadata = meta.info)
>> >>
>> >> ##Which was then aggregated together##
>> >>
>> >> > pheno <- new("AnnotatedDataFrame", + data = sample.info, + varMetadata = meta.info)
>> >>
>> >>   >my.experiments <- new("ExpressionSet", + exprs=fake.data, phenoData=pheno)
>> >>    > my.experiments
>> >> ExpressionSet (storageMode: lockedEnvironment) assayData: 200 features, 8 samples element names: exprs
>> >>
>> >> ##The following deals with further manipulating the phenoData##
>> >> phenoData
>> >>    sampleNames: 1, 2, ..., 8 (8 total) varLabels and varMetadata description: spl: Sample Name stat: Cancer Status
>> >>
>> >> featureData
>> >>  featureNames: 1, 2, ..., 200 (200 total) fvarLabels and fvarMetadata description: none
>> >> experimentData:  use 'experimentData(object)'
>> >> Annotation:
>> >>
>> >> ##At this point is when the dataset 'Dilution was read in through data(Dilution)
>> >>
>> >> which was made an object of the AnnotatedDataFrame via
>> >>
>> >> >phenoData(Dilution)
>> >>
>> >> My apologies in advance as I know the above info. pertains to functions carried out strictly through BioConducor, but is the only context I can provide for what I am trying to do.
>> >>
>> >> Best,
>> >>
>> >> Spencer
>> >>
>> >>
>> >> On Fri, Jul 19, 2019 at 10:23 AM Sarah Goslee <[hidden email]> wrote:
>> >>>
>> >>> Hi Spencer,
>> >>>
>> >>> Your description doesn't make any sense to me. If anno is already an R
>> >>> object, what are you trying to do with it?
>> >>>
>> >>> data() is for loading datasets that come with packages; if your object
>> >>> is already an R object in your environment, then there's no need for
>> >>> it.
>> >>>
>> >>> It sounds like you are possibly working through an example provided
>> >>> elsewhere, that has sample data loaded with data(). If so, then you do
>> >>> not need that step for your own data. You just need to import it into
>> >>> R in the correct format.
>> >>>
>> >>> If that doesn't help, then I think we need more information on what
>> >>> you're trying to do.
>> >>>
>> >>> Sarah
>> >>>
>> >>> On Fri, Jul 19, 2019 at 10:18 AM Spencer Brackett
>> >>> <[hidden email]> wrote:
>> >>> >
>> >>> > Hello,
>> >>> >
>> >>> >   I am trying to create a data set from an object called ‘anno’ in my
>> >>> > environment. I’ve tried arguments like saveRDS(anno, file = “”) and
>> >>> > save(anno, file “.RData”) to save the object as a file to see if that will
>> >>> > work, but it seems for the particular procedure I am trying to carry out, I
>> >>> > need to transpose the object to a data set. Any ideas as to how I might do
>> >>> > this? For reference, my next step in manipulating the data contained in the
>> >>> > object is data(), which evidently does not work for reading in data frame
>> >>> > objects as data(“file/object name).
>> >>> >
>> >>> > Best,
>> >>> >
>> >>> > Spencer
>> >>> >\



--
Sarah Goslee (she/her)
http://www.numberwright.com

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

Re: How to create a data set from object/data frame?

Spencer Brackett
Thank you for the advice

On Fri, Jul 19, 2019 at 2:25 PM Sarah Goslee <[hidden email]> wrote:

> Okay, at this point I have three suggestions, because you're clearly
> not yet understanding the R workflow.
>
> 1. Read at least the Intro to R manual.
> https://cran.r-project.org/doc/manuals/R-intro.pdf
> 2. Go through your sample code carefully, step by step, using
> functions like str() and head() to look at the R objects produced at
> each step, using ? to investigate functions you aren't familiar with,
> and thinking as you go how those R objects do and don't resemble the
> data you have.
> 3. If 1 and 2 don't help, you need to consult with your advisor,
> mentor, or if there's nobody local to you that can help, the author of
> the sample code you're using.
>
> I don't have your sample code, don't have your data, am not familiar
> with the specific functions you are using, and don't have time to
> become familiar. You need to both improve your R understanding and
> seek out guidance, ideally from someone whose job it is to help you.
>
> Best,
> Sarah
>
> On Fri, Jul 19, 2019 at 1:47 PM Spencer Brackett
> <[hidden email]> wrote:
> >
> > Okay. I am a little confused as to how to proceed with that. The next
> part of the procedure as seen below appears to be substituting information
> from this fake data set into the following arguments in order to
> >
> >  sample.info <- data.frame( + spl=paste('A', 1:8, sep=''), +
> stat=rep(c('cancer' , 'healthy'), each=4))
> >
> > ##Then a meta data.frame object was created to give more intelligible
> labels##
> >
> > > meta.info <- data.frame (labelDescription = + c('Sample Name' ,
> 'Cancer Status')) Then we put them all together: > pheno <-
> new("AnnotatedDataFrame", + data = sample.info, + varMetadata = meta.info)
> >
> > ##Which was then aggregated together##
> >
> > > pheno <- new("AnnotatedDataFrame", + data = sample.info, +
> varMetadata = meta.info)
> >
> >   >my.experiments <- new("ExpressionSet", + exprs=fake.data,
> phenoData=pheno)
> >    > my.experiments
> > ExpressionSet (storageMode: lockedEnvironment) assayData: 200 features,
> 8 samples element names: exprs
> >
> > ##The following deals with further manipulating the phenoData##
> > phenoData
> >    sampleNames: 1, 2, ..., 8 (8 total) varLabels and varMetadata
> description: spl: Sample Name stat: Cancer Status
> >
> > featureData
> >    featureNames: 1, 2, ..., 200 (200 total)
> >    fvarLabels and fvarMetadata description: none
> > experimentData:  use 'experimentData(object)'
> > Annotation:
> >
> > ##At this point is when the dataset 'Dilution' was read in through
> data(Dilution)
> >
> >  >library(affydata)
> >  > data(Dilution)
> >
> > which was made an object of the AnnotatedDataFrame via
> > >Dilution
> > >phenoData(Dilution)
> > >pData(Dilution)
> >
> > ##To access the probesets###
> >
> >  > geneNames(Dilution)[1:3] [1] "100_g_at" "1000_at" "1001_at"
> > > random.affyid <- sample(geneNames(Dilution), 1)
> > > # random.affyid <- '34803_at'
> > > ps <- probeset(Dilution, random.affyid)[[1]]
> >
> > How would I substitute in my anno object to achieve this?
> >
> >
> >
> >
> > On Fri, Jul 19, 2019 at 1:32 PM Sarah Goslee <[hidden email]>
> wrote:
> >>
> >> You don't need fake.data or rnorm(), which was used to generate the
> fake data.
> >>
> >> You need to use your real data for the analysis, not anything randomly
> >> generated for example purposes, or anything included with a package
> >> for example purposes.
> >>
> >> In both cases, those are just worked examples.You need to analyze your
> >> own comparable data.
> >>
> >> Sarah
> >>
> >> On Fri, Jul 19, 2019 at 12:17 PM Spencer Brackett
> >> <[hidden email]> wrote:
> >> >
> >> > Sarah,
> >> >
> >> > Thank you for the reference to ?data. Upon further research into the
> matter, I think I can provide a simpler explanation than the one previously
> provided. I am trying to reproduce the following code with an object --
> 'anno' -- in my data frame/environment.
> >> >
> >> >   >fake.data <- matrix(rnorm(8*200), ncol=8)
> >> >
> >> > I found the number of columns with >ncol(anno)  , which is 3
> >> >
> >> > How do I find rnorm when I don't have the data table (saved as the
> 'anno' object) mean or standard dev. ?
> >> >
> >> > I will try reading in the data object through read.table() now,
> though won't that just print the data or a subset thereof into my R console?
> >> >
> >> >
> >> >
> >> > On Fri, Jul 19, 2019 at 10:46 AM Spencer Brackett <
> [hidden email]> wrote:
> >> >>
> >> >> Sarah,
> >> >>
> >> >>   I am trying to extract phenoData (ie sample information) from the
> object as part of a procedure to analyze my array for probe sets, which I
> realize is under the BioConducter package Biobase and not relevant to this
> mailing list.
> >> >>
> >> >>   Yes the original procedure uses data from the Dilution dataset
> hosted in the AffyBatch package affydata. Previous to this part of the
> procedure, a dataset was create via..
> >> >>
> >> >>   >fake.data <- matrix(rnorm(8*200), ncol=8)
> >> >> ##Then phenotype (sample) data was generated in this example
> through... ##
> >> >>
> >> >>   sample.info <- data.frame( + spl=paste('A', 1:8, sep=''), +
> stat=rep(c('cancer' , 'healthy'), each=4))
> >> >>
> >> >> ##Then a meta data.frame object was created to give more
> intelligible labels##
> >> >>
> >> >> > meta.info <- data.frame (labelDescription = + c('Sample Name' ,
> 'Cancer Status')) Then we put them all together: > pheno <-
> new("AnnotatedDataFrame", + data = sample.info, + varMetadata = meta.info)
> >> >>
> >> >> ##Which was then aggregated together##
> >> >>
> >> >> > pheno <- new("AnnotatedDataFrame", + data = sample.info, +
> varMetadata = meta.info)
> >> >>
> >> >>   >my.experiments <- new("ExpressionSet", + exprs=fake.data,
> phenoData=pheno)
> >> >>    > my.experiments
> >> >> ExpressionSet (storageMode: lockedEnvironment) assayData: 200
> features, 8 samples element names: exprs
> >> >>
> >> >> ##The following deals with further manipulating the phenoData##
> >> >> phenoData
> >> >>    sampleNames: 1, 2, ..., 8 (8 total) varLabels and varMetadata
> description: spl: Sample Name stat: Cancer Status
> >> >>
> >> >> featureData
> >> >>  featureNames: 1, 2, ..., 200 (200 total) fvarLabels and
> fvarMetadata description: none
> >> >> experimentData:  use 'experimentData(object)'
> >> >> Annotation:
> >> >>
> >> >> ##At this point is when the dataset 'Dilution was read in through
> data(Dilution)
> >> >>
> >> >> which was made an object of the AnnotatedDataFrame via
> >> >>
> >> >> >phenoData(Dilution)
> >> >>
> >> >> My apologies in advance as I know the above info. pertains to
> functions carried out strictly through BioConducor, but is the only context
> I can provide for what I am trying to do.
> >> >>
> >> >> Best,
> >> >>
> >> >> Spencer
> >> >>
> >> >>
> >> >> On Fri, Jul 19, 2019 at 10:23 AM Sarah Goslee <
> [hidden email]> wrote:
> >> >>>
> >> >>> Hi Spencer,
> >> >>>
> >> >>> Your description doesn't make any sense to me. If anno is already
> an R
> >> >>> object, what are you trying to do with it?
> >> >>>
> >> >>> data() is for loading datasets that come with packages; if your
> object
> >> >>> is already an R object in your environment, then there's no need for
> >> >>> it.
> >> >>>
> >> >>> It sounds like you are possibly working through an example provided
> >> >>> elsewhere, that has sample data loaded with data(). If so, then you
> do
> >> >>> not need that step for your own data. You just need to import it
> into
> >> >>> R in the correct format.
> >> >>>
> >> >>> If that doesn't help, then I think we need more information on what
> >> >>> you're trying to do.
> >> >>>
> >> >>> Sarah
> >> >>>
> >> >>> On Fri, Jul 19, 2019 at 10:18 AM Spencer Brackett
> >> >>> <[hidden email]> wrote:
> >> >>> >
> >> >>> > Hello,
> >> >>> >
> >> >>> >   I am trying to create a data set from an object called ‘anno’
> in my
> >> >>> > environment. I’ve tried arguments like saveRDS(anno, file = “”)
> and
> >> >>> > save(anno, file “.RData”) to save the object as a file to see if
> that will
> >> >>> > work, but it seems for the particular procedure I am trying to
> carry out, I
> >> >>> > need to transpose the object to a data set. Any ideas as to how I
> might do
> >> >>> > this? For reference, my next step in manipulating the data
> contained in the
> >> >>> > object is data(), which evidently does not work for reading in
> data frame
> >> >>> > objects as data(“file/object name).
> >> >>> >
> >> >>> > Best,
> >> >>> >
> >> >>> > Spencer
> >> >>> >\
>
>
>
> --
> Sarah Goslee (she/her)
> http://www.numberwright.com
>

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

Re: How to create a data set from object/data frame?

Jim Lemon-4
In reply to this post by Spencer Brackett
Hi Spencer,
While Sarah has already given you very good advice, there is a rough
method of checking whether one data set can be substituted for
another:

str(anno)
str(Dilution)

If you're lucky and the objects are not too complicated, this will
give you a start on whether one can be substituted for the other. For
example, if one is a vector and the other is a complicated list of
lists, forget it. If the two STRuctures look pretty much the same,
you've got a chance.

Jim

On Sat, Jul 20, 2019 at 12:18 AM Spencer Brackett
<[hidden email]> wrote:

>
> Hello,
>
>   I am trying to create a data set from an object called ‘anno’ in my
> environment. I’ve tried arguments like saveRDS(anno, file = “”) and
> save(anno, file “.RData”) to save the object as a file to see if that will
> work, but it seems for the particular procedure I am trying to carry out, I
> need to transpose the object to a data set. Any ideas as to how I might do
> this? For reference, my next step in manipulating the data contained in the
> object is data(), which evidently does not work for reading in data frame
> objects as data(“file/object name).
>
> Best,
>
> Spencer
>
>         [[alternative HTML version deleted]]
>
> ______________________________________________
> [hidden email] mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

Re: How to create a data set from object/data frame?

Richard O'Keefe-2
In reply to this post by Spencer Brackett
I'm having a little trouble believing what I'm seeing.
To the best of my knowledge,
sample.info <- data.frame( + spl=paste('A', 1:8, sep=''), +
stat=rep(c('cancer' , 'healthy'), each=4))
is not legal R syntax, and R 3.6.1 agrees with me
Error: unexpected '=' in "x <- data.frame(+ spl="

Then I see  + c('Sample Name' , 'Cancer
Status')
which R doesn't like either, for obvious reasons.
Error in +c("Sample Name", "Cancer\nStatus") :
  invalid argument to unary operator

Are you sure all these + signs are in your actual code?
What do you expect them to do?

On Sat, 20 Jul 2019 at 02:46, Spencer Brackett <
[hidden email]> wrote:

> Sarah,
>
>   I am trying to extract phenoData (ie sample information) from the object
> as part of a procedure to analyze my array for probe sets, which I realize
> is under the BioConducter package Biobase and not relevant to this mailing
> list.
>
>   Yes the original procedure uses data from the Dilution dataset hosted in
> the AffyBatch package affydata. Previous to this part of the procedure, a
> dataset was create via..
>
>   >fake.data <- matrix(rnorm(8*200), ncol=8)
> ##Then phenotype (sample) data was generated in this example through... ##
>
>   sample.info <- data.frame( + spl=paste('A', 1:8, sep=''), +
> stat=rep(c('cancer' , 'healthy'), each=4))
>
> ##Then a meta data.frame object was created to give more intelligible
> labels##
>
> > meta.info <- data.frame (labelDescription = + c('Sample Name' , 'Cancer
> Status')) Then we put them all together: > pheno <-
> new("AnnotatedDataFrame", + data = sample.info, + varMetadata = meta.info)
>
> ##Which was then aggregated together##
>
> > pheno <- new("AnnotatedDataFrame", + data = sample.info, + varMetadata =
> meta.info)
>
>   >my.experiments <- new("ExpressionSet", + exprs=fake.data,
> phenoData=pheno)
>    > my.experiments
> ExpressionSet (storageMode: lockedEnvironment) assayData: 200 features, 8
> samples element names: exprs
>
> ##The following deals with further manipulating the phenoData##
> phenoData
>    sampleNames: 1, 2, ..., 8 (8 total) varLabels and varMetadata
> description: spl: Sample Name stat: Cancer Status
>
> featureData
>  featureNames: 1, 2, ..., 200 (200 total) fvarLabels and fvarMetadata
> description: none
> experimentData:  use 'experimentData(object)'
> Annotation:
>
> ##At this point is when the dataset 'Dilution was read in through
> data(Dilution)
>
> which was made an object of the AnnotatedDataFrame via
>
> >phenoData(Dilution)
>
> My apologies in advance as I know the above info. pertains to functions
> carried out strictly through BioConducor, but is the only context I can
> provide for what I am trying to do.
>
> Best,
>
> Spencer
>
>
> On Fri, Jul 19, 2019 at 10:23 AM Sarah Goslee <[hidden email]>
> wrote:
>
> > Hi Spencer,
> >
> > Your description doesn't make any sense to me. If anno is already an R
> > object, what are you trying to do with it?
> >
> > data() is for loading datasets that come with packages; if your object
> > is already an R object in your environment, then there's no need for
> > it.
> >
> > It sounds like you are possibly working through an example provided
> > elsewhere, that has sample data loaded with data(). If so, then you do
> > not need that step for your own data. You just need to import it into
> > R in the correct format.
> >
> > If that doesn't help, then I think we need more information on what
> > you're trying to do.
> >
> > Sarah
> >
> > On Fri, Jul 19, 2019 at 10:18 AM Spencer Brackett
> > <[hidden email]> wrote:
> > >
> > > Hello,
> > >
> > >   I am trying to create a data set from an object called ‘anno’ in my
> > > environment. I’ve tried arguments like saveRDS(anno, file = “”) and
> > > save(anno, file “.RData”) to save the object as a file to see if that
> > will
> > > work, but it seems for the particular procedure I am trying to carry
> > out, I
> > > need to transpose the object to a data set. Any ideas as to how I might
> > do
> > > this? For reference, my next step in manipulating the data contained in
> > the
> > > object is data(), which evidently does not work for reading in data
> frame
> > > objects as data(“file/object name).
> > >
> > > Best,
> > >
> > > Spencer
> > >
> > >         [[alternative HTML version deleted]]
> > >
> > > ______________________________________________
> > > [hidden email] mailing list -- To UNSUBSCRIBE and more, see
> > > https://stat.ethz.ch/mailman/listinfo/r-help
> > > PLEASE do read the posting guide
> > http://www.R-project.org/posting-guide.html
> > > and provide commented, minimal, self-contained, reproducible code.
> >
> >
> >
> > --
> > Sarah Goslee (she/her)
> > http://www.numberwright.com
> >
>
>         [[alternative HTML version deleted]]
>
> ______________________________________________
> [hidden email] mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

Re: How to create a data set from object/data frame?

Richard O'Keefe-2
In reply to this post by Sarah Goslee
No, read.table() *isn't* about printing.
If you have data stored as text in a tabular format,
you use read.data, read.csv, read.csv2, read.delim, or read.delim2
to read it.  This returns a new data frame.  Example:
> x <- read.table(textConnection(c(
+ "A B",
+ "1 2",
+ "3 4")), TRUE)

> x
  A B
1 1 2
2 3 4

Reading the table and storing it in x does not result in anything being
printed.
It's asking for the value of an expression that gets you printout.


On Sat, 20 Jul 2019 at 05:33, Sarah Goslee <[hidden email]> wrote:

> You don't need fake.data or rnorm(), which was used to generate the fake
> data.
>
> You need to use your real data for the analysis, not anything randomly
> generated for example purposes, or anything included with a package
> for example purposes.
>
> In both cases, those are just worked examples.You need to analyze your
> own comparable data.
>
> Sarah
>
> On Fri, Jul 19, 2019 at 12:17 PM Spencer Brackett
> <[hidden email]> wrote:
> >
> > Sarah,
> >
> > Thank you for the reference to ?data. Upon further research into the
> matter, I think I can provide a simpler explanation than the one previously
> provided. I am trying to reproduce the following code with an object --
> 'anno' -- in my data frame/environment.
> >
> >   >fake.data <- matrix(rnorm(8*200), ncol=8)
> >
> > I found the number of columns with >ncol(anno)  , which is 3
> >
> > How do I find rnorm when I don't have the data table (saved as the
> 'anno' object) mean or standard dev. ?
> >
> > I will try reading in the data object through read.table() now, though
> won't that just print the data or a subset thereof into my R console?
> >
> >
> >
> > On Fri, Jul 19, 2019 at 10:46 AM Spencer Brackett <
> [hidden email]> wrote:
> >>
> >> Sarah,
> >>
> >>   I am trying to extract phenoData (ie sample information) from the
> object as part of a procedure to analyze my array for probe sets, which I
> realize is under the BioConducter package Biobase and not relevant to this
> mailing list.
> >>
> >>   Yes the original procedure uses data from the Dilution dataset hosted
> in the AffyBatch package affydata. Previous to this part of the procedure,
> a dataset was create via..
> >>
> >>   >fake.data <- matrix(rnorm(8*200), ncol=8)
> >> ##Then phenotype (sample) data was generated in this example through...
> ##
> >>
> >>   sample.info <- data.frame( + spl=paste('A', 1:8, sep=''), +
> stat=rep(c('cancer' , 'healthy'), each=4))
> >>
> >> ##Then a meta data.frame object was created to give more intelligible
> labels##
> >>
> >> > meta.info <- data.frame (labelDescription = + c('Sample Name' ,
> 'Cancer Status')) Then we put them all together: > pheno <-
> new("AnnotatedDataFrame", + data = sample.info, + varMetadata = meta.info)
> >>
> >> ##Which was then aggregated together##
> >>
> >> > pheno <- new("AnnotatedDataFrame", + data = sample.info, +
> varMetadata = meta.info)
> >>
> >>   >my.experiments <- new("ExpressionSet", + exprs=fake.data,
> phenoData=pheno)
> >>    > my.experiments
> >> ExpressionSet (storageMode: lockedEnvironment) assayData: 200 features,
> 8 samples element names: exprs
> >>
> >> ##The following deals with further manipulating the phenoData##
> >> phenoData
> >>    sampleNames: 1, 2, ..., 8 (8 total) varLabels and varMetadata
> description: spl: Sample Name stat: Cancer Status
> >>
> >> featureData
> >>  featureNames: 1, 2, ..., 200 (200 total) fvarLabels and fvarMetadata
> description: none
> >> experimentData:  use 'experimentData(object)'
> >> Annotation:
> >>
> >> ##At this point is when the dataset 'Dilution was read in through
> data(Dilution)
> >>
> >> which was made an object of the AnnotatedDataFrame via
> >>
> >> >phenoData(Dilution)
> >>
> >> My apologies in advance as I know the above info. pertains to functions
> carried out strictly through BioConducor, but is the only context I can
> provide for what I am trying to do.
> >>
> >> Best,
> >>
> >> Spencer
> >>
> >>
> >> On Fri, Jul 19, 2019 at 10:23 AM Sarah Goslee <[hidden email]>
> wrote:
> >>>
> >>> Hi Spencer,
> >>>
> >>> Your description doesn't make any sense to me. If anno is already an R
> >>> object, what are you trying to do with it?
> >>>
> >>> data() is for loading datasets that come with packages; if your object
> >>> is already an R object in your environment, then there's no need for
> >>> it.
> >>>
> >>> It sounds like you are possibly working through an example provided
> >>> elsewhere, that has sample data loaded with data(). If so, then you do
> >>> not need that step for your own data. You just need to import it into
> >>> R in the correct format.
> >>>
> >>> If that doesn't help, then I think we need more information on what
> >>> you're trying to do.
> >>>
> >>> Sarah
> >>>
> >>> On Fri, Jul 19, 2019 at 10:18 AM Spencer Brackett
> >>> <[hidden email]> wrote:
> >>> >
> >>> > Hello,
> >>> >
> >>> >   I am trying to create a data set from an object called ‘anno’ in my
> >>> > environment. I’ve tried arguments like saveRDS(anno, file = “”) and
> >>> > save(anno, file “.RData”) to save the object as a file to see if
> that will
> >>> > work, but it seems for the particular procedure I am trying to carry
> out, I
> >>> > need to transpose the object to a data set. Any ideas as to how I
> might do
> >>> > this? For reference, my next step in manipulating the data contained
> in the
> >>> > object is data(), which evidently does not work for reading in data
> frame
> >>> > objects as data(“file/object name).
> >>> >
> >>> > Best,
> >>> >
> >>> > Spencer
> >>> >
> >>> >         [[alternative HTML version deleted]]
> >>> >
> >>> > ______________________________________________
> >>> > [hidden email] mailing list -- To UNSUBSCRIBE and more, see
> >>> > https://stat.ethz.ch/mailman/listinfo/r-help
> >>> > PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> >>> > and provide commented, minimal, self-contained, reproducible code.
> >>>
> >>>
>
> ______________________________________________
> [hidden email] mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.