[R] CoxPH multivariate frailty model with coxph (survival)

2019-07-19 Thread Denise b
 Dear R users,

I am interested in estimating the effects of a treatment on two
time-to-event traits (on simulated data), accounting for the dependency
between the two time-to-event outcomes.

I precise that the events are NOT recurrent, NOT competitive, NOT ordered.
The individuals are NOT related and can have 0, 1 or the 2 events (in any
ordered).

So, I specified a time-to-event model with one Cox PH hazard function for
each outcome.
The two hazard functions are linked by a common subject-specific frailty
term (gamma distribution) to account for the dependency. The likelihood
function of that model would include two risks sets (1 for eachoutcome)
connected via the shared frailty term.

To fit that model, I used the coxph function (survival R package, T.
Thernaud):
coxph( Surv(Time, Status) ~ treatment*Event_type + strata(Event_type) +
frailty(ID), data=example)
- where example is my dataset, with 2*N individuals (2 rows for each
individual, corresponding to each time-to-event outcome)
- Time = c(Time_outcome1, Time_outcome2)
- Status=c(Event_outcome1, Event_outcome2)
- Event_type=c(rep(0,length(Time_outcome1)),rep(1,length(Time_outcome2))
- ID=c(ID,ID)

So, the model implies different baseline hazard function for each outcome
(argument strata) and estimate a treatment effect for each event type(
treatment*Event_type).

Although the model returns some estimates close to what I expected
(simulation study), the problem is that most of the examples I found with
this type of formulation are for competitive time-to-event models (as
presented in Therneau's and Grambush's book "Modeling survival
data"  (pages 240-260 and 175-185) and also in some info I found on
internet).

So, I am wondering if some of you have the same or different interpretation
of mime.
Otherwise do you have other functions to recommend me to fit the desired
model, such as coxme...? I also checked the package " mets" which also
describes several examples for competitive time-to-event traits, but not
for NON competitive events.

Thanks in advance for your help,
Denise

[[alternative HTML version deleted]]

__
R-help@r-project.org 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.


Re: [R] Check to see if a value is included within intervals

2019-07-19 Thread Jeff Newmiller
There is no reason for you to tell anyone on this list how they should 
accomplish your goal... we are not a free (or paid) programming service.

If you are in fact obligated to use your  proposed approach, then you are most 
likely doing homework and this list is expressly not for homework (re-read the 
Posting Guide).

If you are doing this on your own then go now and experiment with the 
findInterval function that Bert suggested. We are here to offer you guidance 
and you need to do the learning yourself.

On July 19, 2019 6:30:59 PM CDT, Marine Regis  wrote:
>Thank you very much Bert for your answer. I would like reproduce the
>same results as the code below:
>
>ta <- 100
>tb <- 140
>tc <- 40
>td <- 85
>
>datF <- data.frame(t = 1:3650, e = NA)
>dat <- data.frame(a = seq(1, 3650, 365),
>  b = seq(ta, 3650, 365),
>  c = seq(ta + 1, 3650, 365),
>  d = seq(ta + tb, 3650, 365),
>  e = seq(ta + tb +1, 3650, 365),
>  f = seq(ta + tb + tc, 3650, 365),
>  g = seq(ta + tb + tc + 1, 3650, 365),
>  h = seq(ta + tb + tc + td, 3650, 365))
>
>datF$e <- ifelse((datF$t %in% unlist(Map(`:`, dat$a, dat$b))), 1,
>   ifelse((datF$t %in% unlist(Map(`:`, dat$e, dat$f))), -1, 0))
>
>To reproduce these results, I would like to use a code that looks like
>the code below (i.e., without data frames and R functions):
>a <- 100
>b <- 140
>c <- 40
>d <- 85
>y1 <- a + b + c + d
>
>t1 <- seq(1, y1*10, 1)
>t2 <- t1/y1 - floor(t1/y1)
>p1 <- a/y1
>p2 <- p1 + a/y1
>p3 <- p2 + b/y1
>p4 <- p3 + c/y1
>
>test <- 1*(t2 <= p1)- 1*(t2 > p2)*(t2 <= p3)
>
>Thank you very much for your help.
>Have a nice day
>Marine
>
>
>
>De : Bert Gunter 
>Envoy� : samedi 20 juillet 2019 00:46
>� : Marine Regis 
>Cc : r-help@r-project.org 
>Objet : Re: [R] Check to see if a value is included within intervals
>
>If I understand correctly (make sure that I do!), ?findInterval should
>essentially do what you want.
>
>In your example (thanks!), I assume that:
>1) The cutpoints defining your intervals are increasing, so p1 < p2 <
>p3  (p4 is unused)
>2) You want to know which t2's are in the two intervals t2 <= p1  and
>p2 < t2 <= p3.
>
>If that is correct,
>
>fi <- findInterval(t2, c(p1, p2, p3))
>
>will give you a vector of 0's, 1's, 2's, and 3's. Indices with 0's are
>those for which t2 <= p1. Indices with 2's are those for which p2 <= p3.   1's are for indices with p1 t2's > p3.
>
>Function parameters can control whether intervals are open or closed on
>left and/or right.
>
>Cheers,
>Bert
>
>
>On Fri, Jul 19, 2019 at 3:11 PM Marine Regis
>mailto:marine.re...@hotmail.fr>> wrote:
>Hello all,
>
>The R code below tests if values of the variable �t� are included or
>not within intervals that are defined from the data frame dat. The
>expected results are displayed using the function "rle" (see code
>below). Here is the code:
>
>ta <- 100
>tb <- 140
>tc <- 40
>td <- 85
>
>datF <- data.frame(t = 1:3650, e = NA)
>dat <- data.frame(a = seq(1, 3650, 365),
>  b = seq(ta, 3650, 365),
>  c = seq(ta + 1, 3650, 365),
>  d = seq(ta + tb, 3650, 365),
>  e = seq(ta + tb +1, 3650, 365),
>  f = seq(ta + tb + tc, 3650, 365),
>  g = seq(ta + tb + tc + 1, 3650, 365),
>  h = seq(ta + tb + tc + td, 3650, 365))
>
>datF$e <- ifelse((datF$t %in% unlist(Map(`:`, dat$a, dat$b))), 1,
>   ifelse((datF$t %in% unlist(Map(`:`, dat$e, dat$f))), -1, 0))
>
>## Validation
>y <- rle(datF$e)
>y$lengths[y$values==1]
>y$lengths[y$values==0]
>y$lengths[y$values==-1]
>
>
>The code works but I would like to obtain the same results without
>using data frames and the function �Map�. Here is an example:
>
>a <- 100
>b <- 140
>c <- 40
>d <- 85
>y1 <- a + b + c + d
>
>t1 <- seq(1, y1*10, 1)
>t2 <- t1/y1 - floor(t1/y1)
>p1 <- a/y1
>p2 <- p1 + a/y1
>p3 <- p2 + b/y1
>p4 <- p3 + c/y1
>
>test <- 1*(t2 <= p1)- 1*(t2 > p2)*(t2 <= p3)
>
>## Validation
>y <- rle(test)
>y$lengths[y$values==1]
>y$lengths[y$values==0]
>y$lengths[y$values==-1]
>
>Using this code, the results are not correct.
>
>Any help would be greatly appreciated.
>Many thanks
>Marine
>
>
>
>
>
>
>[[alternative HTML version deleted]]
>
>__
>R-help@r-project.org 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]]

-- 
Sent from my phone. Please excuse my brevity.

__
R-help@r-project.org 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-

Re: [R] Check to see if a value is included within intervals

2019-07-19 Thread Marine Regis
Thank you very much Bert for your answer. I would like reproduce the same 
results as the code below:

ta <- 100
tb <- 140
tc <- 40
td <- 85

datF <- data.frame(t = 1:3650, e = NA)
dat <- data.frame(a = seq(1, 3650, 365),
  b = seq(ta, 3650, 365),
  c = seq(ta + 1, 3650, 365),
  d = seq(ta + tb, 3650, 365),
  e = seq(ta + tb +1, 3650, 365),
  f = seq(ta + tb + tc, 3650, 365),
  g = seq(ta + tb + tc + 1, 3650, 365),
  h = seq(ta + tb + tc + td, 3650, 365))

datF$e <- ifelse((datF$t %in% unlist(Map(`:`, dat$a, dat$b))), 1,
 ifelse((datF$t %in% unlist(Map(`:`, dat$e, dat$f))), -1, 0))

To reproduce these results, I would like to use a code that looks like the code 
below (i.e., without data frames and R functions):
a <- 100
b <- 140
c <- 40
d <- 85
y1 <- a + b + c + d

t1 <- seq(1, y1*10, 1)
t2 <- t1/y1 - floor(t1/y1)
p1 <- a/y1
p2 <- p1 + a/y1
p3 <- p2 + b/y1
p4 <- p3 + c/y1

test <- 1*(t2 <= p1)- 1*(t2 > p2)*(t2 <= p3)

Thank you very much for your help.
Have a nice day
Marine



De : Bert Gunter 
Envoy� : samedi 20 juillet 2019 00:46
� : Marine Regis 
Cc : r-help@r-project.org 
Objet : Re: [R] Check to see if a value is included within intervals

If I understand correctly (make sure that I do!), ?findInterval should 
essentially do what you want.

In your example (thanks!), I assume that:
1) The cutpoints defining your intervals are increasing, so p1 < p2 < p3  (p4 
is unused)
2) You want to know which t2's are in the two intervals t2 <= p1  and p2 < t2 
<= p3.

If that is correct,

fi <- findInterval(t2, c(p1, p2, p3))

will give you a vector of 0's, 1's, 2's, and 3's. Indices with 0's are those 
for which t2 <= p1. Indices with 2's are those for which p2  p3.

Function parameters can control whether intervals are open or closed on left 
and/or right.

Cheers,
Bert


On Fri, Jul 19, 2019 at 3:11 PM Marine Regis 
mailto:marine.re...@hotmail.fr>> wrote:
Hello all,

The R code below tests if values of the variable �t� are included or not within 
intervals that are defined from the data frame dat. The expected results are 
displayed using the function "rle" (see code below). Here is the code:

ta <- 100
tb <- 140
tc <- 40
td <- 85

datF <- data.frame(t = 1:3650, e = NA)
dat <- data.frame(a = seq(1, 3650, 365),
  b = seq(ta, 3650, 365),
  c = seq(ta + 1, 3650, 365),
  d = seq(ta + tb, 3650, 365),
  e = seq(ta + tb +1, 3650, 365),
  f = seq(ta + tb + tc, 3650, 365),
  g = seq(ta + tb + tc + 1, 3650, 365),
  h = seq(ta + tb + tc + td, 3650, 365))

datF$e <- ifelse((datF$t %in% unlist(Map(`:`, dat$a, dat$b))), 1,
 ifelse((datF$t %in% unlist(Map(`:`, dat$e, dat$f))), -1, 0))

## Validation
y <- rle(datF$e)
y$lengths[y$values==1]
y$lengths[y$values==0]
y$lengths[y$values==-1]


The code works but I would like to obtain the same results without using data 
frames and the function �Map�. Here is an example:

a <- 100
b <- 140
c <- 40
d <- 85
y1 <- a + b + c + d

t1 <- seq(1, y1*10, 1)
t2 <- t1/y1 - floor(t1/y1)
p1 <- a/y1
p2 <- p1 + a/y1
p3 <- p2 + b/y1
p4 <- p3 + c/y1

test <- 1*(t2 <= p1)- 1*(t2 > p2)*(t2 <= p3)

## Validation
y <- rle(test)
y$lengths[y$values==1]
y$lengths[y$values==0]
y$lengths[y$values==-1]

Using this code, the results are not correct.

Any help would be greatly appreciated.
Many thanks
Marine






[[alternative HTML version deleted]]

__
R-help@r-project.org 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]]

__
R-help@r-project.org 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.


Re: [R] Check to see if a value is included within intervals

2019-07-19 Thread Bert Gunter
If I understand correctly (make sure that I do!), ?findInterval should
essentially do what you want.

In your example (thanks!), I assume that:
1) The cutpoints defining your intervals are increasing, so p1 < p2 < p3
(p4 is unused)
2) You want to know which t2's are in the two intervals t2 <= p1  and p2 <
t2 <= p3.

If that is correct,

fi <- findInterval(t2, c(p1, p2, p3))

will give you a vector of 0's, 1's, 2's, and 3's. Indices with 0's are
those for which t2 <= p1. Indices with 2's are those for which p2 
p3.

Function parameters can control whether intervals are open or closed on
left and/or right.

Cheers,
Bert


On Fri, Jul 19, 2019 at 3:11 PM Marine Regis 
wrote:

> Hello all,
>
> The R code below tests if values of the variable “t” are included or not
> within intervals that are defined from the data frame dat. The expected
> results are displayed using the function "rle" (see code below). Here is
> the code:
>
> ta <- 100
> tb <- 140
> tc <- 40
> td <- 85
>
> datF <- data.frame(t = 1:3650, e = NA)
> dat <- data.frame(a = seq(1, 3650, 365),
>   b = seq(ta, 3650, 365),
>   c = seq(ta + 1, 3650, 365),
>   d = seq(ta + tb, 3650, 365),
>   e = seq(ta + tb +1, 3650, 365),
>   f = seq(ta + tb + tc, 3650, 365),
>   g = seq(ta + tb + tc + 1, 3650, 365),
>   h = seq(ta + tb + tc + td, 3650, 365))
>
> datF$e <- ifelse((datF$t %in% unlist(Map(`:`, dat$a, dat$b))), 1,
>  ifelse((datF$t %in% unlist(Map(`:`, dat$e, dat$f))), -1,
> 0))
>
> ## Validation
> y <- rle(datF$e)
> y$lengths[y$values==1]
> y$lengths[y$values==0]
> y$lengths[y$values==-1]
>
>
> The code works but I would like to obtain the same results without using
> data frames and the function “Map”. Here is an example:
>
> a <- 100
> b <- 140
> c <- 40
> d <- 85
> y1 <- a + b + c + d
>
> t1 <- seq(1, y1*10, 1)
> t2 <- t1/y1 - floor(t1/y1)
> p1 <- a/y1
> p2 <- p1 + a/y1
> p3 <- p2 + b/y1
> p4 <- p3 + c/y1
>
> test <- 1*(t2 <= p1)- 1*(t2 > p2)*(t2 <= p3)
>
> ## Validation
> y <- rle(test)
> y$lengths[y$values==1]
> y$lengths[y$values==0]
> y$lengths[y$values==-1]
>
> Using this code, the results are not correct.
>
> Any help would be greatly appreciated.
> Many thanks
> Marine
>
>
>
>
>
>
> [[alternative HTML version deleted]]
>
> __
> R-help@r-project.org 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]]

__
R-help@r-project.org 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.


[R] Check to see if a value is included within intervals

2019-07-19 Thread Marine Regis
Hello all,

The R code below tests if values of the variable �t� are included or not within 
intervals that are defined from the data frame dat. The expected results are 
displayed using the function "rle" (see code below). Here is the code:

ta <- 100
tb <- 140
tc <- 40
td <- 85

datF <- data.frame(t = 1:3650, e = NA)
dat <- data.frame(a = seq(1, 3650, 365),
  b = seq(ta, 3650, 365),
  c = seq(ta + 1, 3650, 365),
  d = seq(ta + tb, 3650, 365),
  e = seq(ta + tb +1, 3650, 365),
  f = seq(ta + tb + tc, 3650, 365),
  g = seq(ta + tb + tc + 1, 3650, 365),
  h = seq(ta + tb + tc + td, 3650, 365))

datF$e <- ifelse((datF$t %in% unlist(Map(`:`, dat$a, dat$b))), 1,
 ifelse((datF$t %in% unlist(Map(`:`, dat$e, dat$f))), -1, 0))

## Validation
y <- rle(datF$e)
y$lengths[y$values==1]
y$lengths[y$values==0]
y$lengths[y$values==-1]


The code works but I would like to obtain the same results without using data 
frames and the function �Map�. Here is an example:

a <- 100
b <- 140
c <- 40
d <- 85
y1 <- a + b + c + d

t1 <- seq(1, y1*10, 1)
t2 <- t1/y1 - floor(t1/y1)
p1 <- a/y1
p2 <- p1 + a/y1
p3 <- p2 + b/y1
p4 <- p3 + c/y1

test <- 1*(t2 <= p1)- 1*(t2 > p2)*(t2 <= p3)

## Validation
y <- rle(test)
y$lengths[y$values==1]
y$lengths[y$values==0]
y$lengths[y$values==-1]

Using this code, the results are not correct.

Any help would be greatly appreciated.
Many thanks
Marine






[[alternative HTML version deleted]]

__
R-help@r-project.org 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.


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

2019-07-19 Thread Spencer Brackett
Thank you for the advice

On Fri, Jul 19, 2019 at 2:25 PM Sarah Goslee  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
>  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 
> 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
> >>  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 <
> spbracket...@saintjosephhs.com> 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)

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

2019-07-19 Thread 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
 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  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
>>  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 
>> >  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

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

2019-07-19 Thread Spencer Brackett
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  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
>  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 <
> spbracket...@saintjosephhs.com> 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
> >>
> >>
> >>

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

2019-07-19 Thread 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 <
spbracket...@saintjosephhs.com> 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 
> 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
>>  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,

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

2019-07-19 Thread 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
 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 
>  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  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
>>>  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]]
>>> >
>>> > __
>>> > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
>>> > https://stat.ethz.ch/mailman/listinfo/r-help
>>> > PLE

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

2019-07-19 Thread 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 <
spbracket...@saintjosephhs.com> 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 
> 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
>>  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]]
>> >
>> > __
>> > R-help@r-project.org 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]]

__
R-help@r-project.org 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, m

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

2019-07-19 Thread 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
 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  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
>>  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

__
R-help@r-project.org 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.


Re: [R] xyplot() conventions for multiple conditioning vars lattice pkg

2019-07-19 Thread Bert Gunter
xyplot(formula(result), result,  type = c( 'g','l'))

See ?formula (the part about the dataframe method) for details.

Bert Gunter

"The trouble with having an open mind is that people keep coming along and
sticking things into it."
-- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )


On Fri, Jul 19, 2019 at 6:28 AM Doran, Harold  wrote:

> Here is a toy example of what I want
>
> library(lattice)
> result <- data.frame(score = 1:10, theta = seq(from = -5, to = 5, length =
> 10))
> result$theta2 <- result$theta + .3
> xyplot(score ~ theta + theta2, result,  type = c('g', 'l'))
>
> However, in reality, the number of variables along the x-axis will vary in
> unknown ways. So, I collect them in a matrix, similar to something like
>
> thetaMat <- cbind(result$theta, result$theta2)
>
> I recall at one point being able to pass a matrix of some form, such as
> xyplot(score ~ thetaMat[,1:ncol(thetaMat)], result, type = c('g', 'l'))
>
> This fails, and I am cannot recall the right usage for doing this without
> having to stack the columns (which I'm hoping to avoid).
>
> Can anyone suggest the right usage for this concept?
>
> Thanks
>
> Harold
>
>
> [[alternative HTML version deleted]]
>
> __
> R-help@r-project.org 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]]

__
R-help@r-project.org 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.


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

2019-07-19 Thread 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 
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
>  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]]
> >
> > __
> > R-help@r-project.org 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]]

__
R-help@r-project.org 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.


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

2019-07-19 Thread 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
 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]]
>
> __
> R-help@r-project.org 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

__
R-help@r-project.org 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.


[R] How to create a data set from object/data frame?

2019-07-19 Thread 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]]

__
R-help@r-project.org 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.


[R] xyplot() conventions for multiple conditioning vars lattice pkg

2019-07-19 Thread Doran, Harold
Here is a toy example of what I want

library(lattice)
result <- data.frame(score = 1:10, theta = seq(from = -5, to = 5, length = 10))
result$theta2 <- result$theta + .3
xyplot(score ~ theta + theta2, result,  type = c('g', 'l'))

However, in reality, the number of variables along the x-axis will vary in 
unknown ways. So, I collect them in a matrix, similar to something like

thetaMat <- cbind(result$theta, result$theta2)

I recall at one point being able to pass a matrix of some form, such as
xyplot(score ~ thetaMat[,1:ncol(thetaMat)], result, type = c('g', 'l'))

This fails, and I am cannot recall the right usage for doing this without 
having to stack the columns (which I'm hoping to avoid).

Can anyone suggest the right usage for this concept?

Thanks

Harold


[[alternative HTML version deleted]]

__
R-help@r-project.org 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.