Re: [R] Relatively Simple Maximization Using Optim Doesnt Optimize
> L= 1006.536 > L= 1006.537 > L= 1006.535 > It appears to have chosen step size 0.001, not 0.1. It should be > getting adequate accuracy in both 1st and 2nd derivatives. > Those little ripples you see in the plot are not relevant. I'm impressed. But you're still wrong. Try this: - #not good R code! v = numeric () production3 <- function(L){ #store in vector v <<- c (v, L) budget=10 Lcost=12 Kcost=15 K=(budget-L*Lcost)/Kcost machines=0.05*L^(2/3)*K^(1/3) return(machines) } optim.sol <- optim (1001, production3 ,method="CG", control = list(fnscale=-1) ) n = length (v) print (n) plot (1:n ,v, type="l") - After 401 iterations (on my computer), the algorithm hasn't converged. And I note it's converging extremely slowly, so I don't see any argument for increasing the number of iterations. And try this: (The first 30 steps). - plot (1:30 ,v [1:30], type="l") - Little ripples aren't going anywhere... __ 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] Relatively Simple Maximization Using Optim Doesnt Optimize
On 12/03/2020 7:25 p.m., Abby Spurdle wrote: There is nothing in that plot to indicate that the result given by optim() should be accepted as optimal. The numerical approximation to the derivative is 0.055851 everywhere in your graph That wasn't how I intended the plot to be interpreted. By default, the step size (in x) is 1e-5, which seems like a moderate step size. optim() uses a much larger one. You can see it if you run this code after yours: production2 <- function(L){ abline(v=L);cat("L=", L, "\n") # Add this in to see L values budget=10 Lcost=12 Kcost=15 K=(budget-L*Lcost)/Kcost machines=0.05*L^(2/3)*K^(1/3) return(machines) } optim.sol <- optim (1001, production2 ,method="CG", control = list(fnscale=-1) ) You'll get just 3 evaluations within the scale of your plot. They are at L= 1006.536 L= 1006.537 L= 1006.535 It appears to have chosen step size 0.001, not 0.1. It should be getting adequate accuracy in both 1st and 2nd derivatives. Those little ripples you see in the plot are not relevant. However, at that level, the numerical approximation is very badly behaved. And if the step size is decreased, things get worse. I haven't checked all the technical details of the optim function. But any reliance on numerical approximations of the derivative, have a high chance of running into problems using a function like this. __ 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] Relatively Simple Maximization Using Optim Doesnt Optimize
> There is nothing in that plot to indicate that the result given by > optim() should be accepted as optimal. The numerical approximation to > the derivative is 0.055851 everywhere in your graph That wasn't how I intended the plot to be interpreted. By default, the step size (in x) is 1e-5, which seems like a moderate step size. However, at that level, the numerical approximation is very badly behaved. And if the step size is decreased, things get worse. I haven't checked all the technical details of the optim function. But any reliance on numerical approximations of the derivative, have a high chance of running into problems using a function like this. __ 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] Relatively Simple Maximization Using Optim Doesnt Optimize
On 12/03/2020 1:22 p.m., Abby Spurdle wrote: I'm sorry, Duncan. But I disagree. This is not a "bug" in optim function, as such. (Or at least, there's nothing in this discussion to suggest that there's a bug). But rather a floating point arithmetic related problem. The OP's function looks simple enough, at first glance. But it's not. Plotting a numerical approximation of the derivative, makes the problem more apparent: There is nothing in that plot to indicate that the result given by optim() should be accepted as optimal. The numerical approximation to the derivative is 0.055851 everywhere in your graph, with numerical errors out in the 8th decimal place or later. Clearly the max occurs somewhere to the right of that. Yes, the 2nd derivative calculation will be terrible if R chooses a step size of 0.1 when calculating it, but why would it do that, given that the 1st derivative is 3 orders of magnitude larger? -- plot_derivative <- function (f, a = sol - offset, b = sol + offset, sol, offset=0.001, N=200) { FIRST <- 1:(N - 2) LAST <- 3:N MP <- 2:(N - 1) x <- seq (a, b, length.out=N) y <- f (x) dy <- (y [LAST] - y [FIRST]) / (x [LAST] - x [FIRST]) plot (x [MP], dy, type="l", xlab="x", ylab="dy/dx (approx)") } optim.sol <- optim (1001, production1 ,method="CG", control = list (fnscale=-1) )$par plot_derivative (production1, sol=optim.sol) abline (v=optim.sol, lty=2, col="grey") -- So, I would say the optim function (including the CG method) is doing what it's supposed to do. And collating/expanding on Nash's, Jeff's and Eric's comments: (1) An exact solution can be derived quickly, so using a numerical method is unnecessary, and inefficient. (2) Possible problems with the CG method are noted in the documentation. (3) Numerical approximations of the function's derivative need to be well-behaved for gradient-based numerical methods to work properly. On Fri, Mar 13, 2020 at 3:42 AM Duncan Murdoch wrote: It looks like a bug in the CG method. The other methods in optim() all work fine. CG is documented to be a good choice in high dimensions; why did you choose it for a 1 dim problem? Duncan Murdoch __ 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] Relatively Simple Maximization Using Optim Doesnt Optimize
Hi Abby: Either way, thanks for your efforts with the derivative plot. Note that John Nash is a SERIOUS EXPERT in optimization so I would just go by what he said earlier. Also, I don't want to speak for Duncan but I have a feeling that he meant "inadequacy" in the CG method rather than a bug in the R code. Mark On Thu, Mar 12, 2020 at 5:55 PM Abby Spurdle wrote: > > (1) An exact solution can be derived quickly > > Please disregard note (1) above. > I'm not sure if it was right. > > And one more comment: > > The conjugate gradient method is an established method. > So the question is, is the optim function applying this method or not... > And assuming that it is, then R is definitely doing what it should be > doing. > If not, then I guess it would be a bug... > > __ > 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 make our data normally distributed in R
Hi, Why do you want to re-scale RMSE to 0-1? You can change ylim=(0,1) to ylim=(0, 4600). You may use VEcv (Variance explained by predictive models based on cross-validation) that ranges from 0 to 100% instead. It can be calculated using vecv function in library(spm) or you can convert RMSE to VEcv using tovecv in spm. Hope this helps, Jin On Fri, Mar 13, 2020 at 8:08 AM Neha gupta wrote: > Hi > > I have a regression based data where I get the RMSE results as: > > SVM=3500 > ANN=4600 > R.Forest=2900 > > I want to know how can I make it so that its values comes as 0-1 > > I plot the boxplot for it to indicate their RMSE values and used, > ylim=(0,1), but the boxplot which works for RMSE values like 3500 etc, but > when I use ylim=(0,1), all the boxplots suddenly disappears. What should I > do for it? > > Thanks > > [[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. > -- Jin [[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] Installing Packages
Thank you all - that was helpful. I guess I assumes everything that got pushed up to the server was already compiled. -Original Message- From: Duncan Murdoch Sent: Wednesday, March 11, 2020 10:10 AM To: reichm...@sbcglobal.net; r-help@r-project.org Subject: Re: [R] Installing Packages On 11/03/2020 7:46 a.m., Jeff Reichman wrote: > R-Help > > > > Recently I've started receiving the following message when updating > packages > - "Do you want to install from sources the packages which need compilation." > I generally click "Yes," but what is this asking me. That is it > appears to be re-compiling certain packages? Why? > As the others answered: that's because compiled versions aren't available on the server yet. What they didn't say is why you might want to say "no". You would say that if you expect the compile on your own system to fail, perhaps because you don't have compilers or special libraries installed. R can install packages whose source is all in R, but needs external tools to install packages that incorporate other languages like C, C++ and Fortran. Even if you have those compilers, some packages will need to link to libraries outside of R. If you say "no", then R will look for an older compiled version of the package and install that. This might cause trouble if some other package depends on the latest version of its dependencies: you won't be able to install the latest version of that package either. I'd recommend trying with "yes", then trying again with "no" if there were any install failures. Duncan Murdoch __ 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 make our data normally distributed in R
Thanks Hasan and Rui Rui, as you mentioned As for the second question, if your RMSE vector had values in the range 2900 to 4600 and the y axis limits are c(0, 1), how can you expect to see anything? Then what should be the values of ylim in boxplots? I need to show them as boxplot between 0-1 or 1-10, even 10-100 but it will be very awkward if the boxplot shows the values of 3500 etc. Regards On Thu, Mar 12, 2020 at 11:51 PM Rui Barradas wrote: > Hello, > > To rescale data so that their values are between 0 and 1, use this > function: > > > scale01 <- function(x, na.rm = FALSE){ >(x - min(x, na.rm = na.rm))/(max(x, na.rm = na.rm) - min(x, na.rm = > na.rm)) > } > > x <- c(SVM=3500, > ANN=4600, > R.Forest=2900) > > scale01(x) > # SVM ANN R.Forest > #0.3529412 1.000 0.000 > > > See base R function ?scale for another way of scaling data. > > As for the second question, if your RMSE vector had values in the range > 2900 to 4600 and the y axis limits are c(0, 1), how can you expect to > see anything? > > Hope this helps, > > Rui Barradas > > > Às 21:08 de 12/03/20, Neha gupta escreveu: > > Hi > > > > I have a regression based data where I get the RMSE results as: > > > > SVM=3500 > > ANN=4600 > > R.Forest=2900 > > > > I want to know how can I make it so that its values comes as 0-1 > > > > I plot the boxplot for it to indicate their RMSE values and used, > > ylim=(0,1), but the boxplot which works for RMSE values like 3500 etc, > but > > when I use ylim=(0,1), all the boxplots suddenly disappears. What should > I > > do for it? > > > > Thanks > > > > [[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 make our data normally distributed in R
Hello, To rescale data so that their values are between 0 and 1, use this function: scale01 <- function(x, na.rm = FALSE){ (x - min(x, na.rm = na.rm))/(max(x, na.rm = na.rm) - min(x, na.rm = na.rm)) } x <- c(SVM=3500, ANN=4600, R.Forest=2900) scale01(x) # SVM ANN R.Forest #0.3529412 1.000 0.000 See base R function ?scale for another way of scaling data. As for the second question, if your RMSE vector had values in the range 2900 to 4600 and the y axis limits are c(0, 1), how can you expect to see anything? Hope this helps, Rui Barradas Às 21:08 de 12/03/20, Neha gupta escreveu: Hi I have a regression based data where I get the RMSE results as: SVM=3500 ANN=4600 R.Forest=2900 I want to know how can I make it so that its values comes as 0-1 I plot the boxplot for it to indicate their RMSE values and used, ylim=(0,1), but the boxplot which works for RMSE values like 3500 etc, but when I use ylim=(0,1), all the boxplots suddenly disappears. What should I do for it? Thanks [[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-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] Relatively Simple Maximization Using Optim Doesnt Optimize
> (1) An exact solution can be derived quickly Please disregard note (1) above. I'm not sure if it was right. And one more comment: The conjugate gradient method is an established method. So the question is, is the optim function applying this method or not... And assuming that it is, then R is definitely doing what it should be doing. If not, then I guess it would be a bug... __ 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 make our data normally distributed in R
Hi I have a regression based data where I get the RMSE results as: SVM=3500 ANN=4600 R.Forest=2900 I want to know how can I make it so that its values comes as 0-1 I plot the boxplot for it to indicate their RMSE values and used, ylim=(0,1), but the boxplot which works for RMSE values like 3500 etc, but when I use ylim=(0,1), all the boxplots suddenly disappears. What should I do for it? Thanks [[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] Relatively Simple Maximization Using Optim Doesnt Optimize
I'm sorry, Duncan. But I disagree. This is not a "bug" in optim function, as such. (Or at least, there's nothing in this discussion to suggest that there's a bug). But rather a floating point arithmetic related problem. The OP's function looks simple enough, at first glance. But it's not. Plotting a numerical approximation of the derivative, makes the problem more apparent: -- plot_derivative <- function (f, a = sol - offset, b = sol + offset, sol, offset=0.001, N=200) { FIRST <- 1:(N - 2) LAST <- 3:N MP <- 2:(N - 1) x <- seq (a, b, length.out=N) y <- f (x) dy <- (y [LAST] - y [FIRST]) / (x [LAST] - x [FIRST]) plot (x [MP], dy, type="l", xlab="x", ylab="dy/dx (approx)") } optim.sol <- optim (1001, production1 ,method="CG", control = list (fnscale=-1) )$par plot_derivative (production1, sol=optim.sol) abline (v=optim.sol, lty=2, col="grey") -- So, I would say the optim function (including the CG method) is doing what it's supposed to do. And collating/expanding on Nash's, Jeff's and Eric's comments: (1) An exact solution can be derived quickly, so using a numerical method is unnecessary, and inefficient. (2) Possible problems with the CG method are noted in the documentation. (3) Numerical approximations of the function's derivative need to be well-behaved for gradient-based numerical methods to work properly. On Fri, Mar 13, 2020 at 3:42 AM Duncan Murdoch wrote: > > It looks like a bug in the CG method. The other methods in optim() all > work fine. CG is documented to be a good choice in high dimensions; why > did you choose it for a 1 dim problem? > > Duncan Murdoch __ 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 do I add text lables on QQ plot
Thank you! On Thu, Mar 12, 2020 at 12:47 PM Abby Spurdle wrote: > > The plotting character is determined by the pch argument. > i.e. You need to specify the pch argument in the legend call. > > Here's the R code to preview the first 20 plotting characters: > > > plot (1:20, rep (0, 20), pch=1:20, ylim = c (-5, 5) ) > > text (1:20, rep (1, 20), 1:20) > > Empty circles, have a pch value of 1. > Solid circles, have a pch value of 16. > In general, to set the color, use the col argument. > > So, you could add the following to your legend call: > > > ..., pch=16, col = c ("red", "blue"), ... > > And remove the fill argument. > > > > On 3/13/20, Ana Marija wrote: > > I could make legend via this: > > qq(fdr2_sorted$FDR.q.val2, main = "RG_All", pch = 16, > > col=fdr1_sorted$group, cex = 0.8, las = 1) > > legend('topleft', legend = c('up-regulated', 'down-regulated'), fill = > > c('red', 'blue'),bty="o") > > > > but this gives me squares in legend. How do I write this code in order > > to have circles in the legend? > > > > On Thu, Mar 12, 2020 at 11:04 AM Ana Marija > > wrote: > >> > >> Also how would I add legend to this plot? > >> > >> I searched qqman pages and there is no mention of that __ 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 do I add text lables on QQ plot
The plotting character is determined by the pch argument. i.e. You need to specify the pch argument in the legend call. Here's the R code to preview the first 20 plotting characters: > plot (1:20, rep (0, 20), pch=1:20, ylim = c (-5, 5) ) > text (1:20, rep (1, 20), 1:20) Empty circles, have a pch value of 1. Solid circles, have a pch value of 16. In general, to set the color, use the col argument. So, you could add the following to your legend call: > ..., pch=16, col = c ("red", "blue"), ... And remove the fill argument. On 3/13/20, Ana Marija wrote: > I could make legend via this: > qq(fdr2_sorted$FDR.q.val2, main = "RG_All", pch = 16, > col=fdr1_sorted$group, cex = 0.8, las = 1) > legend('topleft', legend = c('up-regulated', 'down-regulated'), fill = > c('red', 'blue'),bty="o") > > but this gives me squares in legend. How do I write this code in order > to have circles in the legend? > > On Thu, Mar 12, 2020 at 11:04 AM Ana Marija > wrote: >> >> Also how would I add legend to this plot? >> >> I searched qqman pages and there is no mention of that __ 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 do I add text lables on QQ plot
Hi Ana, I've already given you an example of using the text function with vectors. I note that this thread contains a lot of duplication. I'd recommend people read the whole thread before posting. On Fri, Mar 13, 2020 at 3:42 AM Ana Marija wrote: > > Hi Michael, > > can you please send me a line of code showing how it would be done. > > Thanks > Ana > > On Thu, Mar 12, 2020 at 9:16 AM Michael Dewey wrote: > > > > Dear Ana > > > > You can specify the first three parameters to text() as vectors so it is > > all done in one call. That may or may not answer your question. > > > > Michael > > > > On 12/03/2020 14:08, Ana Marija wrote: > > > HI David, > > > > > > thank you for getting back to me. > > > > > > Is there is a way for qq() to pick up text label names on its own or I > > > have to specify each one manually? > > > like in this example: > > > text( 2, 6, "arbitrary") > > > > > > this is dput for > > > > > >> a=head(fdr2_sorted) > > >> dput(a) > > > structure(list(NAME = c("GO_DNA_PACKAGING_COMPLEX", > > > "GO_PROTEIN_DNA_COMPLEX", > > > "GO_RESPONSE_TO_TYPE_I_INTERFERON", "GO_RESPONSE_TO_INTERFERON_GAMMA", > > > "GO_CELLULAR_RESPONSE_TO_INTERFERON_GAMMA", "GO_GRANULOCYTE_MIGRATION" > > > ), `GS follow link to MSigDB` = c("GO_DNA_PACKAGING_COMPLEX", > > > "GO_PROTEIN_DNA_COMPLEX", "GO_RESPONSE_TO_TYPE_I_INTERFERON", > > > "GO_RESPONSE_TO_INTERFERON_GAMMA", > > > "GO_CELLULAR_RESPONSE_TO_INTERFERON_GAMMA", > > > "GO_GRANULOCYTE_MIGRATION"), `GS DETAILS` = c("Details ...", > > > "Details ...", "Details ...", "Details ...", "Details ...", "Details ..." > > > ), SIZE = c(77L, 132L, 52L, 101L, 85L, 43L), ES = c(0.6757226, > > > 0.59581786, -0.7521569, -0.63704145, -0.6571892, -0.7332099), > > > NES = c(2.466745, 2.3465202, -2.5331483, -2.4204733, -2.4021535, > > > -2.3989832), `NOM p-val` = c(0, 0, 0, 0, 0, 0), `FDR q-val` = c(0, > > > 0, 0, 0, 0, 0), `FWER p-val` = c(0, 0, 0, 0, 0, 0), `RANK AT MAX` = > > > c(L, > > > 1516L, 1427L, 1819L, 1216L, 491L), `LEADING EDGE` = c("tags=43%, > > > list=10%, signal=47%", > > > "tags=39%, list=13%, signal=45%", "tags=54%, list=12%, signal=61%", > > > "tags=45%, list=16%, signal=52%", "tags=38%, list=11%, signal=42%", > > > "tags=28%, list=4%, signal=29%"), V12 = c(NA, NA, NA, NA, > > > NA, NA), FDR.q.val2 = c(1e-10, 1e-10, 1e-10, 1e-10, 1e-10, > > > 1e-10)), class = c("data.table", "data.frame"), row.names = c(NA, > > > -6L), .internal.selfref = ) > > > > > >> b=head(fdr1_sorted) > > >> dput(b) > > > structure(list(NAME = c("GO_DNA_PACKAGING_COMPLEX", > > > "GO_PROTEIN_DNA_COMPLEX", > > > "GO_RESPONSE_TO_TYPE_I_INTERFERON", "GO_RESPONSE_TO_INTERFERON_GAMMA", > > > "GO_CELLULAR_RESPONSE_TO_INTERFERON_GAMMA", "GO_GRANULOCYTE_MIGRATION" > > > ), `GS follow link to MSigDB` = c("GO_DNA_PACKAGING_COMPLEX", > > > "GO_PROTEIN_DNA_COMPLEX", "GO_RESPONSE_TO_TYPE_I_INTERFERON", > > > "GO_RESPONSE_TO_INTERFERON_GAMMA", > > > "GO_CELLULAR_RESPONSE_TO_INTERFERON_GAMMA", > > > "GO_GRANULOCYTE_MIGRATION"), `GS DETAILS` = c("Details ...", > > > "Details ...", "Details ...", "Details ...", "Details ...", "Details ..." > > > ), SIZE = c(77L, 132L, 52L, 101L, 85L, 43L), ES = c(0.6757226, > > > 0.59581786, -0.7521569, -0.63704145, -0.6571892, -0.7332099), > > > NES = c(2.466745, 2.3465202, -2.5331483, -2.4204733, -2.4021535, > > > -2.3989832), `NOM p-val` = c(0, 0, 0, 0, 0, 0), `FDR q-val` = c(0, > > > 0, 0, 0, 0, 0), `FWER p-val` = c(0, 0, 0, 0, 0, 0), `RANK AT MAX` = > > > c(L, > > > 1516L, 1427L, 1819L, 1216L, 491L), `LEADING EDGE` = c("tags=43%, > > > list=10%, signal=47%", > > > "tags=39%, list=13%, signal=45%", "tags=54%, list=12%, signal=61%", > > > "tags=45%, list=16%, signal=52%", "tags=38%, list=11%, signal=42%", > > > "tags=28%, list=4%, signal=29%"), V12 = c(NA, NA, NA, NA, > > > NA, NA), group = c(2, 2, 4, 4, 4, 4), FDR.q.val2 = c(1e-10, > > > 1e-10, 1e-10, 1e-10, 1e-10, 1e-10)), class = c("data.table", > > > "data.frame"), row.names = c(NA, -6L), .internal.selfref = > > 0x10400bae0>) > > > > > > library(qqman) > > > qq(fdr2_sorted$FDR.q.val2, main = "RG_All", pch = 16, > > > col=fdr1_sorted$group, cex = 0.8, las = 1) > > > > > > Please advise > > > > > > On Wed, Mar 11, 2020 at 11:21 PM David Winsemius > > > wrote: > > >> > > >> > > >> On 3/10/20 9:51 PM, Ana Marija wrote: > > >>> Hello, > > >>> > > >>> I am making QQ plot via: > > >>> > > >>> library(ggman) > > >>> qq(fdr2_sorted$FDR.q.val2, main = "RG_All", pch = 17, > > >>> col=fdr1_sorted$group, cex = 1, las = 1) > > >> > > >> > > >> I think you may be confusing the audience. There is no qq function in > > >> the ggman package. There is however a qq function in the qqman package. > > >> > > >> > > >> Running the example in help page for qqman::qq and looking at the code > > >> suggests this is a base plot function, so the text function will allow > > >> you to put any particular string within the plot area: > >
Re: [R] Unintended behaviour (possibly bugs)
> Alexey Shipunov > on Tue, 18 Feb 2020 14:34:48 +0900 writes: > Thank you for the detailed explanation. I tend to agree. However, this > behavior is relatively easy to remediate: > This is the piece of the current code: > === > if (!(is.null(labels) && is.null(glabels))) { >nmai <- par("mai") >nmai[2L] <- nmai[4L] + max(linch + goffset, ginch) + 0.1 >par(mai = nmai) > } > === > This is my proposal: > === > yinch <- if (!is.null(ylab)) 0.4 else 0 > if (!(is.null(labels) && is.null(glabels))) { >nmai <- par("mai") >nm.2 <- nmai[4L] + max(if(is.null(ylab)) 0 else 0.4) + linch + goffset, ginch) + 0.1 >if (nmai[2L] < nm.2) > nmai[2L] <- nm.2 >par(mai = nmai) > } > === > Then margins and y-axis labels start to work normally. I wonder if > this (or similar) is possible to introduce into the code? > Alexey Well, I had looked at this back then (~Feb 18), and now had a considerable longer look. Your suggestion makes sense, but then it needs even more work to ensure that the 'ylab' y-axis label will be placed properly. Of course, Deepayan (author of grid-based 'lattice') is right that dotchart()s implementation is pretty hackish ... but then still. I have (+-) fixed this in the sources of "R-devel" the development version of R (which should become R 4.0.0 on April 24 as was announced today). Now, things like this (extended) example work nicely : op <- par(xaxs = "i") # 0 -- 100\% dotchart(t(VADeaths), xlim = c(0,100), bg = "skyblue", main = "Death Rates in Virginia - 1940", xlab = "rate [ % ]", ylab = "Grouping: Age x Urbanity . Gender") par(op) Thank you, Alexey, for your report and bug fix suggestion! Best regards, Martin Maechler ETH Zurich and R Core team > ... 17:37, Deepayan Sarkar : >> >> On Mon, Feb 17, 2020 at 10:24 AM Rui Barradas wrot= > e: >> > >> > Hello, >> > >> > Yes, this is definitely a bug. >> >> I would argue that the only bug here is that the documentation doesn't >> say that 'ylab' may not behave as expected. >> >> dotchart() is mainly designed for 2-way tables (see the VADeaths >> example), but it's implementation is really pretty hackish because it >> has to work within the limited traditional graphics framework. The >> main problem is that dot plots want to put horizontal y-axis labels >> (usually derived from factor levels), which are often longer than the >> default margins, so the margins are modified. Unfortunately they are >> only re-set on exit, and so the ylab that is plotted inside dotchart() >> may be clipped. Traditionally, Cleveland dot plots don't have a y-axis >> label; it's assumed that the factor levels are sufficient (and for >> 2-way tables, there would be two variables, so there is no sensible >> default). >> >> I doubt that dotchart() is worth fixing (except to maybe disallow >> ylab). If you want flexibility, use modern grid-based alternatives >> such as lattice::dotplot() or ggplot2. >> >> -Deepayan >> >> > Even the matrix plot is puzzling, with a "1" as top row sort-of-label >> > but no grid line. I'm trying to follow the source code of dotchart but >> > am yet to understand exactly what it does to decide the margins setting= > s. >> > >> > if (!(is.null(labels) && is.null(glabels))) { >> >nmai <- par("mai") >> >nmai[2L] <- nmai[4L] + max(linch + goffset, ginch) + >> > 0.1 >> >par(mai = nmai) >> > } >> > >> > This should be moved to r-devel? >> > >> > Rui Barradas >> > >> > 03:33 de 17/02/20, Alexey Shipunov escreveu: >> > > John and Rui, thanks! >> > > >> > > However, if we use the proper object, the problem still persists: >> > > >> > > dotchart(c("3"=1, "2"=2, "1"=3), ylab="Ylab") # ylab is invisible >> > > dotchart(c("aa"=1, "b"=2, "cc"=3), ylab="Ylab") # ylab is partly visible (!!!) >> > > dotchart(c("aaa"=1, "bbb"=2, "ccc"=3), ylab="Ylab") # ylab is well visible >> > > >> > > If the object is matrix, ylab is visible: >> > > >> > > dotchart(matrix(1:3, dimnames=list(c("aa","bb","cc"), NULL)), ylab="Ylab") >> > > >> > > But the ?dotchart explicitly says that "x: either a vector or matrix >> > > of numeric values" and then "labels: a vector of labels for each >> > > point. For vectors the default is to use "names(x) = ...". >> > > >> > > So this is likely a bug. Do you agree? >> > > >> > > Alexey >> > > >> > > . 01:55, Rui Barradas : >> > >> >> > >> Hello, >> > >> >> > >> I believe you are wrong, the error is not in dotchart, it's in your >> > >> code. You assume that to plot an object of class "table" is the same as >>
Re: [R] how do I add text lables on QQ plot
I could make legend via this: qq(fdr2_sorted$FDR.q.val2, main = "RG_All", pch = 16, col=fdr1_sorted$group, cex = 0.8, las = 1) legend('topleft', legend = c('up-regulated', 'down-regulated'), fill = c('red', 'blue'),bty="o") but this gives me squares in legend. How do I write this code in order to have circles in the legend? On Thu, Mar 12, 2020 at 11:04 AM Ana Marija wrote: > > Also how would I add legend to this plot? > > I searched qqman pages and there is no mention of that > > qq(fdr2_sorted$FDR.q.val2, main = "RG_All", pch = 16, > col=fdr1_sorted$group, cex = 0.8, las = 1) > > On Thu, Mar 12, 2020 at 9:30 AM Ana Marija > wrote: > > > > Hi Michael, > > > > can you please send me a line of code showing how it would be done. > > > > Thanks > > Ana > > > > On Thu, Mar 12, 2020 at 9:16 AM Michael Dewey > > wrote: > > > > > > Dear Ana > > > > > > You can specify the first three parameters to text() as vectors so it is > > > all done in one call. That may or may not answer your question. > > > > > > Michael > > > > > > On 12/03/2020 14:08, Ana Marija wrote: > > > > HI David, > > > > > > > > thank you for getting back to me. > > > > > > > > Is there is a way for qq() to pick up text label names on its own or I > > > > have to specify each one manually? > > > > like in this example: > > > > text( 2, 6, "arbitrary") > > > > > > > > this is dput for > > > > > > > >> a=head(fdr2_sorted) > > > >> dput(a) > > > > structure(list(NAME = c("GO_DNA_PACKAGING_COMPLEX", > > > > "GO_PROTEIN_DNA_COMPLEX", > > > > "GO_RESPONSE_TO_TYPE_I_INTERFERON", "GO_RESPONSE_TO_INTERFERON_GAMMA", > > > > "GO_CELLULAR_RESPONSE_TO_INTERFERON_GAMMA", "GO_GRANULOCYTE_MIGRATION" > > > > ), `GS follow link to MSigDB` = c("GO_DNA_PACKAGING_COMPLEX", > > > > "GO_PROTEIN_DNA_COMPLEX", "GO_RESPONSE_TO_TYPE_I_INTERFERON", > > > > "GO_RESPONSE_TO_INTERFERON_GAMMA", > > > > "GO_CELLULAR_RESPONSE_TO_INTERFERON_GAMMA", > > > > "GO_GRANULOCYTE_MIGRATION"), `GS DETAILS` = c("Details ...", > > > > "Details ...", "Details ...", "Details ...", "Details ...", "Details > > > > ..." > > > > ), SIZE = c(77L, 132L, 52L, 101L, 85L, 43L), ES = c(0.6757226, > > > > 0.59581786, -0.7521569, -0.63704145, -0.6571892, -0.7332099), > > > > NES = c(2.466745, 2.3465202, -2.5331483, -2.4204733, -2.4021535, > > > > -2.3989832), `NOM p-val` = c(0, 0, 0, 0, 0, 0), `FDR q-val` = c(0, > > > > 0, 0, 0, 0, 0), `FWER p-val` = c(0, 0, 0, 0, 0, 0), `RANK AT MAX` > > > > = c(L, > > > > 1516L, 1427L, 1819L, 1216L, 491L), `LEADING EDGE` = c("tags=43%, > > > > list=10%, signal=47%", > > > > "tags=39%, list=13%, signal=45%", "tags=54%, list=12%, signal=61%", > > > > "tags=45%, list=16%, signal=52%", "tags=38%, list=11%, signal=42%", > > > > "tags=28%, list=4%, signal=29%"), V12 = c(NA, NA, NA, NA, > > > > NA, NA), FDR.q.val2 = c(1e-10, 1e-10, 1e-10, 1e-10, 1e-10, > > > > 1e-10)), class = c("data.table", "data.frame"), row.names = c(NA, > > > > -6L), .internal.selfref = ) > > > > > > > >> b=head(fdr1_sorted) > > > >> dput(b) > > > > structure(list(NAME = c("GO_DNA_PACKAGING_COMPLEX", > > > > "GO_PROTEIN_DNA_COMPLEX", > > > > "GO_RESPONSE_TO_TYPE_I_INTERFERON", "GO_RESPONSE_TO_INTERFERON_GAMMA", > > > > "GO_CELLULAR_RESPONSE_TO_INTERFERON_GAMMA", "GO_GRANULOCYTE_MIGRATION" > > > > ), `GS follow link to MSigDB` = c("GO_DNA_PACKAGING_COMPLEX", > > > > "GO_PROTEIN_DNA_COMPLEX", "GO_RESPONSE_TO_TYPE_I_INTERFERON", > > > > "GO_RESPONSE_TO_INTERFERON_GAMMA", > > > > "GO_CELLULAR_RESPONSE_TO_INTERFERON_GAMMA", > > > > "GO_GRANULOCYTE_MIGRATION"), `GS DETAILS` = c("Details ...", > > > > "Details ...", "Details ...", "Details ...", "Details ...", "Details > > > > ..." > > > > ), SIZE = c(77L, 132L, 52L, 101L, 85L, 43L), ES = c(0.6757226, > > > > 0.59581786, -0.7521569, -0.63704145, -0.6571892, -0.7332099), > > > > NES = c(2.466745, 2.3465202, -2.5331483, -2.4204733, -2.4021535, > > > > -2.3989832), `NOM p-val` = c(0, 0, 0, 0, 0, 0), `FDR q-val` = c(0, > > > > 0, 0, 0, 0, 0), `FWER p-val` = c(0, 0, 0, 0, 0, 0), `RANK AT MAX` > > > > = c(L, > > > > 1516L, 1427L, 1819L, 1216L, 491L), `LEADING EDGE` = c("tags=43%, > > > > list=10%, signal=47%", > > > > "tags=39%, list=13%, signal=45%", "tags=54%, list=12%, signal=61%", > > > > "tags=45%, list=16%, signal=52%", "tags=38%, list=11%, signal=42%", > > > > "tags=28%, list=4%, signal=29%"), V12 = c(NA, NA, NA, NA, > > > > NA, NA), group = c(2, 2, 4, 4, 4, 4), FDR.q.val2 = c(1e-10, > > > > 1e-10, 1e-10, 1e-10, 1e-10, 1e-10)), class = c("data.table", > > > > "data.frame"), row.names = c(NA, -6L), .internal.selfref = > > > 0x10400bae0>) > > > > > > > > library(qqman) > > > > qq(fdr2_sorted$FDR.q.val2, main = "RG_All", pch = 16, > > > > col=fdr1_sorted$group, cex = 0.8, las = 1) > > > > > > > > Please advise > > > > > > > > On Wed, Mar 11, 2020 at 11:21 PM David Winsemius > > > > wrote: > > > >> > > > >> > > > >> On 3/10/20 9:51 PM, Ana Marija wrot
Re: [R] how do I add text lables on QQ plot
Also how would I add legend to this plot? I searched qqman pages and there is no mention of that qq(fdr2_sorted$FDR.q.val2, main = "RG_All", pch = 16, col=fdr1_sorted$group, cex = 0.8, las = 1) On Thu, Mar 12, 2020 at 9:30 AM Ana Marija wrote: > > Hi Michael, > > can you please send me a line of code showing how it would be done. > > Thanks > Ana > > On Thu, Mar 12, 2020 at 9:16 AM Michael Dewey wrote: > > > > Dear Ana > > > > You can specify the first three parameters to text() as vectors so it is > > all done in one call. That may or may not answer your question. > > > > Michael > > > > On 12/03/2020 14:08, Ana Marija wrote: > > > HI David, > > > > > > thank you for getting back to me. > > > > > > Is there is a way for qq() to pick up text label names on its own or I > > > have to specify each one manually? > > > like in this example: > > > text( 2, 6, "arbitrary") > > > > > > this is dput for > > > > > >> a=head(fdr2_sorted) > > >> dput(a) > > > structure(list(NAME = c("GO_DNA_PACKAGING_COMPLEX", > > > "GO_PROTEIN_DNA_COMPLEX", > > > "GO_RESPONSE_TO_TYPE_I_INTERFERON", "GO_RESPONSE_TO_INTERFERON_GAMMA", > > > "GO_CELLULAR_RESPONSE_TO_INTERFERON_GAMMA", "GO_GRANULOCYTE_MIGRATION" > > > ), `GS follow link to MSigDB` = c("GO_DNA_PACKAGING_COMPLEX", > > > "GO_PROTEIN_DNA_COMPLEX", "GO_RESPONSE_TO_TYPE_I_INTERFERON", > > > "GO_RESPONSE_TO_INTERFERON_GAMMA", > > > "GO_CELLULAR_RESPONSE_TO_INTERFERON_GAMMA", > > > "GO_GRANULOCYTE_MIGRATION"), `GS DETAILS` = c("Details ...", > > > "Details ...", "Details ...", "Details ...", "Details ...", "Details ..." > > > ), SIZE = c(77L, 132L, 52L, 101L, 85L, 43L), ES = c(0.6757226, > > > 0.59581786, -0.7521569, -0.63704145, -0.6571892, -0.7332099), > > > NES = c(2.466745, 2.3465202, -2.5331483, -2.4204733, -2.4021535, > > > -2.3989832), `NOM p-val` = c(0, 0, 0, 0, 0, 0), `FDR q-val` = c(0, > > > 0, 0, 0, 0, 0), `FWER p-val` = c(0, 0, 0, 0, 0, 0), `RANK AT MAX` = > > > c(L, > > > 1516L, 1427L, 1819L, 1216L, 491L), `LEADING EDGE` = c("tags=43%, > > > list=10%, signal=47%", > > > "tags=39%, list=13%, signal=45%", "tags=54%, list=12%, signal=61%", > > > "tags=45%, list=16%, signal=52%", "tags=38%, list=11%, signal=42%", > > > "tags=28%, list=4%, signal=29%"), V12 = c(NA, NA, NA, NA, > > > NA, NA), FDR.q.val2 = c(1e-10, 1e-10, 1e-10, 1e-10, 1e-10, > > > 1e-10)), class = c("data.table", "data.frame"), row.names = c(NA, > > > -6L), .internal.selfref = ) > > > > > >> b=head(fdr1_sorted) > > >> dput(b) > > > structure(list(NAME = c("GO_DNA_PACKAGING_COMPLEX", > > > "GO_PROTEIN_DNA_COMPLEX", > > > "GO_RESPONSE_TO_TYPE_I_INTERFERON", "GO_RESPONSE_TO_INTERFERON_GAMMA", > > > "GO_CELLULAR_RESPONSE_TO_INTERFERON_GAMMA", "GO_GRANULOCYTE_MIGRATION" > > > ), `GS follow link to MSigDB` = c("GO_DNA_PACKAGING_COMPLEX", > > > "GO_PROTEIN_DNA_COMPLEX", "GO_RESPONSE_TO_TYPE_I_INTERFERON", > > > "GO_RESPONSE_TO_INTERFERON_GAMMA", > > > "GO_CELLULAR_RESPONSE_TO_INTERFERON_GAMMA", > > > "GO_GRANULOCYTE_MIGRATION"), `GS DETAILS` = c("Details ...", > > > "Details ...", "Details ...", "Details ...", "Details ...", "Details ..." > > > ), SIZE = c(77L, 132L, 52L, 101L, 85L, 43L), ES = c(0.6757226, > > > 0.59581786, -0.7521569, -0.63704145, -0.6571892, -0.7332099), > > > NES = c(2.466745, 2.3465202, -2.5331483, -2.4204733, -2.4021535, > > > -2.3989832), `NOM p-val` = c(0, 0, 0, 0, 0, 0), `FDR q-val` = c(0, > > > 0, 0, 0, 0, 0), `FWER p-val` = c(0, 0, 0, 0, 0, 0), `RANK AT MAX` = > > > c(L, > > > 1516L, 1427L, 1819L, 1216L, 491L), `LEADING EDGE` = c("tags=43%, > > > list=10%, signal=47%", > > > "tags=39%, list=13%, signal=45%", "tags=54%, list=12%, signal=61%", > > > "tags=45%, list=16%, signal=52%", "tags=38%, list=11%, signal=42%", > > > "tags=28%, list=4%, signal=29%"), V12 = c(NA, NA, NA, NA, > > > NA, NA), group = c(2, 2, 4, 4, 4, 4), FDR.q.val2 = c(1e-10, > > > 1e-10, 1e-10, 1e-10, 1e-10, 1e-10)), class = c("data.table", > > > "data.frame"), row.names = c(NA, -6L), .internal.selfref = > > 0x10400bae0>) > > > > > > library(qqman) > > > qq(fdr2_sorted$FDR.q.val2, main = "RG_All", pch = 16, > > > col=fdr1_sorted$group, cex = 0.8, las = 1) > > > > > > Please advise > > > > > > On Wed, Mar 11, 2020 at 11:21 PM David Winsemius > > > wrote: > > >> > > >> > > >> On 3/10/20 9:51 PM, Ana Marija wrote: > > >>> Hello, > > >>> > > >>> I am making QQ plot via: > > >>> > > >>> library(ggman) > > >>> qq(fdr2_sorted$FDR.q.val2, main = "RG_All", pch = 17, > > >>> col=fdr1_sorted$group, cex = 1, las = 1) > > >> > > >> > > >> I think you may be confusing the audience. There is no qq function in > > >> the ggman package. There is however a qq function in the qqman package. > > >> > > >> > > >> Running the example in help page for qqman::qq and looking at the code > > >> suggests this is a base plot function, so the text function will allow > > >> you to put any particular string within the plot area: > > >> >
Re: [R] Relatively Simple Maximization Using Optim Doesnt Optimize
Thanks for the replies. Since I was seeing this glitch with CG in my 1d and 2d formulation of the problem I was trying to figure out what was going on that led to the failure. I'll switch to a more suitable method and keep these considerations in mind. On Thu, Mar 12, 2020, 9:23 AM J C Nash wrote: > As author of CG (at least the code that was used to build it), I can say I > was > never happy with that code. Rcgmin is the replacement I wrote, and I > believe that > could still be improved. > > BUT: > - you have a 1D optimization. Use Brent method and supply bounds. > - I never intended CG (or BFGS or Nelder-Mead or ...) to work for 1D > problems > - as Jeff points out, you need the gradient. I stop Rcgmin and Rvmmin if > user hasn't supplied one, as numerical approximations need to be very > good for these gradient methods > > JN > > On 2020-03-12 10:03 a.m., Jeff Newmiller wrote: > > The help file points out that CG is "fragile" ... and I would expect > that failing to define a gradient function will exacerbate that. > > > > I think you should use a different algorithm or specify a gradient > function. You might also consider working with the more recent optimr > package contributed by Dr Nash, author of the original optim function in R. > > > > On March 12, 2020 2:30:26 AM PDT, Skyler Saleebyan < > skylerbsaleeb...@gmail.com> wrote: > >> I am trying to familiarize myself with optim() with a relatively simple > >> maximization. > >> > >> Description: > >> L and K are two terms which are constrained to add up to a total 10 > >> (with respective weights to each). To map this constraint I plugged K > >> into > >> the function (to make this as simple as possible.) > >> > >> Together these two feed into one nonlinear function which is the > >> product of > >> two monotonic (on the positive interval) functions. Then that numbers > >> is > >> returned in a function fed to optim, which should maximize the output > >> by > >> adjusting L. The whole code is: > >> > >> production1 <- function(L){ > >> budget=10 > >> Lcost=12 > >> Kcost=15 > >> K=(budget-L*Lcost)/Kcost > >> machines=0.05*L^(2/3)*K^(1/3) > >> return(machines) > >> } > >> > >> # production1(6000) #example of number with much higher output vs optim > >> result > >> S1=optim(1001,production1,method="CG",control=list(fnscale=-1)) > >> S1 > >> > >> Output: > >> $par > >> [1] 1006.536 > >> > >> $value > >> [1] 90.54671 > >> > >> $counts > >> function gradient > >> 201 101 > >> > >> $convergence > >> [1] 1 > >> > >> $message > >> NULL > >> > >> > >> For some reason this never explores the problem space and just spits > >> out > >> some answer close to the initial condition. What am I doing wrong? > >> > >> Thanks, > >> Skyler S. > >> > >> [[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 do I add text lables on QQ plot
Hi Michael, can you please send me a line of code showing how it would be done. Thanks Ana On Thu, Mar 12, 2020 at 9:16 AM Michael Dewey wrote: > > Dear Ana > > You can specify the first three parameters to text() as vectors so it is > all done in one call. That may or may not answer your question. > > Michael > > On 12/03/2020 14:08, Ana Marija wrote: > > HI David, > > > > thank you for getting back to me. > > > > Is there is a way for qq() to pick up text label names on its own or I > > have to specify each one manually? > > like in this example: > > text( 2, 6, "arbitrary") > > > > this is dput for > > > >> a=head(fdr2_sorted) > >> dput(a) > > structure(list(NAME = c("GO_DNA_PACKAGING_COMPLEX", > > "GO_PROTEIN_DNA_COMPLEX", > > "GO_RESPONSE_TO_TYPE_I_INTERFERON", "GO_RESPONSE_TO_INTERFERON_GAMMA", > > "GO_CELLULAR_RESPONSE_TO_INTERFERON_GAMMA", "GO_GRANULOCYTE_MIGRATION" > > ), `GS follow link to MSigDB` = c("GO_DNA_PACKAGING_COMPLEX", > > "GO_PROTEIN_DNA_COMPLEX", "GO_RESPONSE_TO_TYPE_I_INTERFERON", > > "GO_RESPONSE_TO_INTERFERON_GAMMA", > > "GO_CELLULAR_RESPONSE_TO_INTERFERON_GAMMA", > > "GO_GRANULOCYTE_MIGRATION"), `GS DETAILS` = c("Details ...", > > "Details ...", "Details ...", "Details ...", "Details ...", "Details ..." > > ), SIZE = c(77L, 132L, 52L, 101L, 85L, 43L), ES = c(0.6757226, > > 0.59581786, -0.7521569, -0.63704145, -0.6571892, -0.7332099), > > NES = c(2.466745, 2.3465202, -2.5331483, -2.4204733, -2.4021535, > > -2.3989832), `NOM p-val` = c(0, 0, 0, 0, 0, 0), `FDR q-val` = c(0, > > 0, 0, 0, 0, 0), `FWER p-val` = c(0, 0, 0, 0, 0, 0), `RANK AT MAX` = > > c(L, > > 1516L, 1427L, 1819L, 1216L, 491L), `LEADING EDGE` = c("tags=43%, > > list=10%, signal=47%", > > "tags=39%, list=13%, signal=45%", "tags=54%, list=12%, signal=61%", > > "tags=45%, list=16%, signal=52%", "tags=38%, list=11%, signal=42%", > > "tags=28%, list=4%, signal=29%"), V12 = c(NA, NA, NA, NA, > > NA, NA), FDR.q.val2 = c(1e-10, 1e-10, 1e-10, 1e-10, 1e-10, > > 1e-10)), class = c("data.table", "data.frame"), row.names = c(NA, > > -6L), .internal.selfref = ) > > > >> b=head(fdr1_sorted) > >> dput(b) > > structure(list(NAME = c("GO_DNA_PACKAGING_COMPLEX", > > "GO_PROTEIN_DNA_COMPLEX", > > "GO_RESPONSE_TO_TYPE_I_INTERFERON", "GO_RESPONSE_TO_INTERFERON_GAMMA", > > "GO_CELLULAR_RESPONSE_TO_INTERFERON_GAMMA", "GO_GRANULOCYTE_MIGRATION" > > ), `GS follow link to MSigDB` = c("GO_DNA_PACKAGING_COMPLEX", > > "GO_PROTEIN_DNA_COMPLEX", "GO_RESPONSE_TO_TYPE_I_INTERFERON", > > "GO_RESPONSE_TO_INTERFERON_GAMMA", > > "GO_CELLULAR_RESPONSE_TO_INTERFERON_GAMMA", > > "GO_GRANULOCYTE_MIGRATION"), `GS DETAILS` = c("Details ...", > > "Details ...", "Details ...", "Details ...", "Details ...", "Details ..." > > ), SIZE = c(77L, 132L, 52L, 101L, 85L, 43L), ES = c(0.6757226, > > 0.59581786, -0.7521569, -0.63704145, -0.6571892, -0.7332099), > > NES = c(2.466745, 2.3465202, -2.5331483, -2.4204733, -2.4021535, > > -2.3989832), `NOM p-val` = c(0, 0, 0, 0, 0, 0), `FDR q-val` = c(0, > > 0, 0, 0, 0, 0), `FWER p-val` = c(0, 0, 0, 0, 0, 0), `RANK AT MAX` = > > c(L, > > 1516L, 1427L, 1819L, 1216L, 491L), `LEADING EDGE` = c("tags=43%, > > list=10%, signal=47%", > > "tags=39%, list=13%, signal=45%", "tags=54%, list=12%, signal=61%", > > "tags=45%, list=16%, signal=52%", "tags=38%, list=11%, signal=42%", > > "tags=28%, list=4%, signal=29%"), V12 = c(NA, NA, NA, NA, > > NA, NA), group = c(2, 2, 4, 4, 4, 4), FDR.q.val2 = c(1e-10, > > 1e-10, 1e-10, 1e-10, 1e-10, 1e-10)), class = c("data.table", > > "data.frame"), row.names = c(NA, -6L), .internal.selfref = > 0x10400bae0>) > > > > library(qqman) > > qq(fdr2_sorted$FDR.q.val2, main = "RG_All", pch = 16, > > col=fdr1_sorted$group, cex = 0.8, las = 1) > > > > Please advise > > > > On Wed, Mar 11, 2020 at 11:21 PM David Winsemius > > wrote: > >> > >> > >> On 3/10/20 9:51 PM, Ana Marija wrote: > >>> Hello, > >>> > >>> I am making QQ plot via: > >>> > >>> library(ggman) > >>> qq(fdr2_sorted$FDR.q.val2, main = "RG_All", pch = 17, > >>> col=fdr1_sorted$group, cex = 1, las = 1) > >> > >> > >> I think you may be confusing the audience. There is no qq function in > >> the ggman package. There is however a qq function in the qqman package. > >> > >> > >> Running the example in help page for qqman::qq and looking at the code > >> suggests this is a base plot function, so the text function will allow > >> you to put any particular string within the plot area: > >> > >> library(qqman) > >> > >> qq(gwasResults$P) > >> text( 2, 6, "arbitrary") # puts text "arbitrary" at postion (x=2, y=6) > >> > >>> > >>> data frames used look like this: > >>> > head(fdr1_sorted) > >> > >> You should use `dput` to post reproducible data examples. > >> > >> HTH; > >> > >> David. > >> > >>> NAME GS follow > >>> link to MSigDB GS DETAILS SIZE ES NES NOM p-val > >>> 1:
Re: [R] Relatively Simple Maximization Using Optim Doesnt Optimize
It looks like a bug in the CG method. The other methods in optim() all work fine. CG is documented to be a good choice in high dimensions; why did you choose it for a 1 dim problem? Duncan Murdoch On 12/03/2020 2:30 a.m., Skyler Saleebyan wrote: I am trying to familiarize myself with optim() with a relatively simple maximization. Description: L and K are two terms which are constrained to add up to a total 10 (with respective weights to each). To map this constraint I plugged K into the function (to make this as simple as possible.) Together these two feed into one nonlinear function which is the product of two monotonic (on the positive interval) functions. Then that numbers is returned in a function fed to optim, which should maximize the output by adjusting L. The whole code is: production1 <- function(L){ budget=10 Lcost=12 Kcost=15 K=(budget-L*Lcost)/Kcost machines=0.05*L^(2/3)*K^(1/3) return(machines) } # production1(6000) #example of number with much higher output vs optim result S1=optim(1001,production1,method="CG",control=list(fnscale=-1)) S1 Output: $par [1] 1006.536 $value [1] 90.54671 $counts function gradient 201 101 $convergence [1] 1 $message NULL For some reason this never explores the problem space and just spits out some answer close to the initial condition. What am I doing wrong? Thanks, Skyler S. [[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-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] Relatively Simple Maximization Using Optim Doesnt Optimize
As author of CG (at least the code that was used to build it), I can say I was never happy with that code. Rcgmin is the replacement I wrote, and I believe that could still be improved. BUT: - you have a 1D optimization. Use Brent method and supply bounds. - I never intended CG (or BFGS or Nelder-Mead or ...) to work for 1D problems - as Jeff points out, you need the gradient. I stop Rcgmin and Rvmmin if user hasn't supplied one, as numerical approximations need to be very good for these gradient methods JN On 2020-03-12 10:03 a.m., Jeff Newmiller wrote: > The help file points out that CG is "fragile" ... and I would expect that > failing to define a gradient function will exacerbate that. > > I think you should use a different algorithm or specify a gradient function. > You might also consider working with the more recent optimr package > contributed by Dr Nash, author of the original optim function in R. > > On March 12, 2020 2:30:26 AM PDT, Skyler Saleebyan > wrote: >> I am trying to familiarize myself with optim() with a relatively simple >> maximization. >> >> Description: >> L and K are two terms which are constrained to add up to a total 10 >> (with respective weights to each). To map this constraint I plugged K >> into >> the function (to make this as simple as possible.) >> >> Together these two feed into one nonlinear function which is the >> product of >> two monotonic (on the positive interval) functions. Then that numbers >> is >> returned in a function fed to optim, which should maximize the output >> by >> adjusting L. The whole code is: >> >> production1 <- function(L){ >> budget=10 >> Lcost=12 >> Kcost=15 >> K=(budget-L*Lcost)/Kcost >> machines=0.05*L^(2/3)*K^(1/3) >> return(machines) >> } >> >> # production1(6000) #example of number with much higher output vs optim >> result >> S1=optim(1001,production1,method="CG",control=list(fnscale=-1)) >> S1 >> >> Output: >> $par >> [1] 1006.536 >> >> $value >> [1] 90.54671 >> >> $counts >> function gradient >> 201 101 >> >> $convergence >> [1] 1 >> >> $message >> NULL >> >> >> For some reason this never explores the problem space and just spits >> out >> some answer close to the initial condition. What am I doing wrong? >> >> Thanks, >> Skyler S. >> >> [[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-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] Relatively Simple Maximization Using Optim Doesnt Optimize
It is possible to work out this problem explicitly. Playing with a few different calls to optim shows that the method="L-BFGS-B" gives the correct answer. I don't have particular insight into why method="CG" is problematic. On Thu, Mar 12, 2020 at 4:12 PM Jeff Newmiller wrote: > The help file points out that CG is "fragile" ... and I would expect that > failing to define a gradient function will exacerbate that. > > I think you should use a different algorithm or specify a gradient > function. You might also consider working with the more recent optimr > package contributed by Dr Nash, author of the original optim function in R. > > On March 12, 2020 2:30:26 AM PDT, Skyler Saleebyan < > skylerbsaleeb...@gmail.com> wrote: > >I am trying to familiarize myself with optim() with a relatively simple > >maximization. > > > >Description: > >L and K are two terms which are constrained to add up to a total 10 > >(with respective weights to each). To map this constraint I plugged K > >into > >the function (to make this as simple as possible.) > > > >Together these two feed into one nonlinear function which is the > >product of > >two monotonic (on the positive interval) functions. Then that numbers > >is > >returned in a function fed to optim, which should maximize the output > >by > >adjusting L. The whole code is: > > > >production1 <- function(L){ > > budget=10 > > Lcost=12 > > Kcost=15 > > K=(budget-L*Lcost)/Kcost > > machines=0.05*L^(2/3)*K^(1/3) > > return(machines) > >} > > > ># production1(6000) #example of number with much higher output vs optim > >result > >S1=optim(1001,production1,method="CG",control=list(fnscale=-1)) > >S1 > > > >Output: > >$par > >[1] 1006.536 > > > >$value > >[1] 90.54671 > > > >$counts > >function gradient > > 201 101 > > > >$convergence > >[1] 1 > > > >$message > >NULL > > > > > >For some reason this never explores the problem space and just spits > >out > >some answer close to the initial condition. What am I doing wrong? > > > >Thanks, > >Skyler S. > > > > [[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. > > -- > 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-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 do I add text lables on QQ plot
Dear Ana You can specify the first three parameters to text() as vectors so it is all done in one call. That may or may not answer your question. Michael On 12/03/2020 14:08, Ana Marija wrote: HI David, thank you for getting back to me. Is there is a way for qq() to pick up text label names on its own or I have to specify each one manually? like in this example: text( 2, 6, "arbitrary") this is dput for a=head(fdr2_sorted) dput(a) structure(list(NAME = c("GO_DNA_PACKAGING_COMPLEX", "GO_PROTEIN_DNA_COMPLEX", "GO_RESPONSE_TO_TYPE_I_INTERFERON", "GO_RESPONSE_TO_INTERFERON_GAMMA", "GO_CELLULAR_RESPONSE_TO_INTERFERON_GAMMA", "GO_GRANULOCYTE_MIGRATION" ), `GS follow link to MSigDB` = c("GO_DNA_PACKAGING_COMPLEX", "GO_PROTEIN_DNA_COMPLEX", "GO_RESPONSE_TO_TYPE_I_INTERFERON", "GO_RESPONSE_TO_INTERFERON_GAMMA", "GO_CELLULAR_RESPONSE_TO_INTERFERON_GAMMA", "GO_GRANULOCYTE_MIGRATION"), `GS DETAILS` = c("Details ...", "Details ...", "Details ...", "Details ...", "Details ...", "Details ..." ), SIZE = c(77L, 132L, 52L, 101L, 85L, 43L), ES = c(0.6757226, 0.59581786, -0.7521569, -0.63704145, -0.6571892, -0.7332099), NES = c(2.466745, 2.3465202, -2.5331483, -2.4204733, -2.4021535, -2.3989832), `NOM p-val` = c(0, 0, 0, 0, 0, 0), `FDR q-val` = c(0, 0, 0, 0, 0, 0), `FWER p-val` = c(0, 0, 0, 0, 0, 0), `RANK AT MAX` = c(L, 1516L, 1427L, 1819L, 1216L, 491L), `LEADING EDGE` = c("tags=43%, list=10%, signal=47%", "tags=39%, list=13%, signal=45%", "tags=54%, list=12%, signal=61%", "tags=45%, list=16%, signal=52%", "tags=38%, list=11%, signal=42%", "tags=28%, list=4%, signal=29%"), V12 = c(NA, NA, NA, NA, NA, NA), FDR.q.val2 = c(1e-10, 1e-10, 1e-10, 1e-10, 1e-10, 1e-10)), class = c("data.table", "data.frame"), row.names = c(NA, -6L), .internal.selfref = ) b=head(fdr1_sorted) dput(b) structure(list(NAME = c("GO_DNA_PACKAGING_COMPLEX", "GO_PROTEIN_DNA_COMPLEX", "GO_RESPONSE_TO_TYPE_I_INTERFERON", "GO_RESPONSE_TO_INTERFERON_GAMMA", "GO_CELLULAR_RESPONSE_TO_INTERFERON_GAMMA", "GO_GRANULOCYTE_MIGRATION" ), `GS follow link to MSigDB` = c("GO_DNA_PACKAGING_COMPLEX", "GO_PROTEIN_DNA_COMPLEX", "GO_RESPONSE_TO_TYPE_I_INTERFERON", "GO_RESPONSE_TO_INTERFERON_GAMMA", "GO_CELLULAR_RESPONSE_TO_INTERFERON_GAMMA", "GO_GRANULOCYTE_MIGRATION"), `GS DETAILS` = c("Details ...", "Details ...", "Details ...", "Details ...", "Details ...", "Details ..." ), SIZE = c(77L, 132L, 52L, 101L, 85L, 43L), ES = c(0.6757226, 0.59581786, -0.7521569, -0.63704145, -0.6571892, -0.7332099), NES = c(2.466745, 2.3465202, -2.5331483, -2.4204733, -2.4021535, -2.3989832), `NOM p-val` = c(0, 0, 0, 0, 0, 0), `FDR q-val` = c(0, 0, 0, 0, 0, 0), `FWER p-val` = c(0, 0, 0, 0, 0, 0), `RANK AT MAX` = c(L, 1516L, 1427L, 1819L, 1216L, 491L), `LEADING EDGE` = c("tags=43%, list=10%, signal=47%", "tags=39%, list=13%, signal=45%", "tags=54%, list=12%, signal=61%", "tags=45%, list=16%, signal=52%", "tags=38%, list=11%, signal=42%", "tags=28%, list=4%, signal=29%"), V12 = c(NA, NA, NA, NA, NA, NA), group = c(2, 2, 4, 4, 4, 4), FDR.q.val2 = c(1e-10, 1e-10, 1e-10, 1e-10, 1e-10, 1e-10)), class = c("data.table", "data.frame"), row.names = c(NA, -6L), .internal.selfref = ) library(qqman) qq(fdr2_sorted$FDR.q.val2, main = "RG_All", pch = 16, col=fdr1_sorted$group, cex = 0.8, las = 1) Please advise On Wed, Mar 11, 2020 at 11:21 PM David Winsemius wrote: On 3/10/20 9:51 PM, Ana Marija wrote: Hello, I am making QQ plot via: library(ggman) qq(fdr2_sorted$FDR.q.val2, main = "RG_All", pch = 17, col=fdr1_sorted$group, cex = 1, las = 1) I think you may be confusing the audience. There is no qq function in the ggman package. There is however a qq function in the qqman package. Running the example in help page for qqman::qq and looking at the code suggests this is a base plot function, so the text function will allow you to put any particular string within the plot area: library(qqman) qq(gwasResults$P) text( 2, 6, "arbitrary") # puts text "arbitrary" at postion (x=2, y=6) data frames used look like this: head(fdr1_sorted) You should use `dput` to post reproducible data examples. HTH; David. NAME GS follow link to MSigDB GS DETAILS SIZE ES NES NOM p-val 1: GO_DNA_PACKAGING_COMPLEX GO_DNA_PACKAGING_COMPLEX Details ... 77 0.6757226 2.466745 0 2: GO_PROTEIN_DNA_COMPLEX GO_PROTEIN_DNA_COMPLEX Details ... 132 0.5958179 2.346520 0 3: GO_RESPONSE_TO_TYPE_I_INTERFERON GO_RESPONSE_TO_TYPE_I_INTERFERON Details ... 52 -0.7521569 -2.533148 0 4: GO_RESPONSE_TO_INTERFERON_GAMMA GO_RESPONSE_TO_INTERFERON_GAMMA Details ... 101 -0.6370415 -2.420473 0 5: GO_CELLULAR_RESPONSE_TO_INTERFERON_GAMMA GO_CELLULAR_RESPONSE_TO_INTERFERON_GAMMA Details ... 85 -0.6571892 -2.402153 0 6: GO_GRANULOCYTE_MIGRATION GO_GRA
Re: [R] Relatively Simple Maximization Using Optim Doesnt Optimize
The help file points out that CG is "fragile" ... and I would expect that failing to define a gradient function will exacerbate that. I think you should use a different algorithm or specify a gradient function. You might also consider working with the more recent optimr package contributed by Dr Nash, author of the original optim function in R. On March 12, 2020 2:30:26 AM PDT, Skyler Saleebyan wrote: >I am trying to familiarize myself with optim() with a relatively simple >maximization. > >Description: >L and K are two terms which are constrained to add up to a total 10 >(with respective weights to each). To map this constraint I plugged K >into >the function (to make this as simple as possible.) > >Together these two feed into one nonlinear function which is the >product of >two monotonic (on the positive interval) functions. Then that numbers >is >returned in a function fed to optim, which should maximize the output >by >adjusting L. The whole code is: > >production1 <- function(L){ > budget=10 > Lcost=12 > Kcost=15 > K=(budget-L*Lcost)/Kcost > machines=0.05*L^(2/3)*K^(1/3) > return(machines) >} > ># production1(6000) #example of number with much higher output vs optim >result >S1=optim(1001,production1,method="CG",control=list(fnscale=-1)) >S1 > >Output: >$par >[1] 1006.536 > >$value >[1] 90.54671 > >$counts >function gradient > 201 101 > >$convergence >[1] 1 > >$message >NULL > > >For some reason this never explores the problem space and just spits >out >some answer close to the initial condition. What am I doing wrong? > >Thanks, >Skyler S. > > [[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. -- 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-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] how do I add text lables on QQ plot
HI David, thank you for getting back to me. Is there is a way for qq() to pick up text label names on its own or I have to specify each one manually? like in this example: text( 2, 6, "arbitrary") this is dput for >a=head(fdr2_sorted) > dput(a) structure(list(NAME = c("GO_DNA_PACKAGING_COMPLEX", "GO_PROTEIN_DNA_COMPLEX", "GO_RESPONSE_TO_TYPE_I_INTERFERON", "GO_RESPONSE_TO_INTERFERON_GAMMA", "GO_CELLULAR_RESPONSE_TO_INTERFERON_GAMMA", "GO_GRANULOCYTE_MIGRATION" ), `GS follow link to MSigDB` = c("GO_DNA_PACKAGING_COMPLEX", "GO_PROTEIN_DNA_COMPLEX", "GO_RESPONSE_TO_TYPE_I_INTERFERON", "GO_RESPONSE_TO_INTERFERON_GAMMA", "GO_CELLULAR_RESPONSE_TO_INTERFERON_GAMMA", "GO_GRANULOCYTE_MIGRATION"), `GS DETAILS` = c("Details ...", "Details ...", "Details ...", "Details ...", "Details ...", "Details ..." ), SIZE = c(77L, 132L, 52L, 101L, 85L, 43L), ES = c(0.6757226, 0.59581786, -0.7521569, -0.63704145, -0.6571892, -0.7332099), NES = c(2.466745, 2.3465202, -2.5331483, -2.4204733, -2.4021535, -2.3989832), `NOM p-val` = c(0, 0, 0, 0, 0, 0), `FDR q-val` = c(0, 0, 0, 0, 0, 0), `FWER p-val` = c(0, 0, 0, 0, 0, 0), `RANK AT MAX` = c(L, 1516L, 1427L, 1819L, 1216L, 491L), `LEADING EDGE` = c("tags=43%, list=10%, signal=47%", "tags=39%, list=13%, signal=45%", "tags=54%, list=12%, signal=61%", "tags=45%, list=16%, signal=52%", "tags=38%, list=11%, signal=42%", "tags=28%, list=4%, signal=29%"), V12 = c(NA, NA, NA, NA, NA, NA), FDR.q.val2 = c(1e-10, 1e-10, 1e-10, 1e-10, 1e-10, 1e-10)), class = c("data.table", "data.frame"), row.names = c(NA, -6L), .internal.selfref = ) > b=head(fdr1_sorted) > dput(b) structure(list(NAME = c("GO_DNA_PACKAGING_COMPLEX", "GO_PROTEIN_DNA_COMPLEX", "GO_RESPONSE_TO_TYPE_I_INTERFERON", "GO_RESPONSE_TO_INTERFERON_GAMMA", "GO_CELLULAR_RESPONSE_TO_INTERFERON_GAMMA", "GO_GRANULOCYTE_MIGRATION" ), `GS follow link to MSigDB` = c("GO_DNA_PACKAGING_COMPLEX", "GO_PROTEIN_DNA_COMPLEX", "GO_RESPONSE_TO_TYPE_I_INTERFERON", "GO_RESPONSE_TO_INTERFERON_GAMMA", "GO_CELLULAR_RESPONSE_TO_INTERFERON_GAMMA", "GO_GRANULOCYTE_MIGRATION"), `GS DETAILS` = c("Details ...", "Details ...", "Details ...", "Details ...", "Details ...", "Details ..." ), SIZE = c(77L, 132L, 52L, 101L, 85L, 43L), ES = c(0.6757226, 0.59581786, -0.7521569, -0.63704145, -0.6571892, -0.7332099), NES = c(2.466745, 2.3465202, -2.5331483, -2.4204733, -2.4021535, -2.3989832), `NOM p-val` = c(0, 0, 0, 0, 0, 0), `FDR q-val` = c(0, 0, 0, 0, 0, 0), `FWER p-val` = c(0, 0, 0, 0, 0, 0), `RANK AT MAX` = c(L, 1516L, 1427L, 1819L, 1216L, 491L), `LEADING EDGE` = c("tags=43%, list=10%, signal=47%", "tags=39%, list=13%, signal=45%", "tags=54%, list=12%, signal=61%", "tags=45%, list=16%, signal=52%", "tags=38%, list=11%, signal=42%", "tags=28%, list=4%, signal=29%"), V12 = c(NA, NA, NA, NA, NA, NA), group = c(2, 2, 4, 4, 4, 4), FDR.q.val2 = c(1e-10, 1e-10, 1e-10, 1e-10, 1e-10, 1e-10)), class = c("data.table", "data.frame"), row.names = c(NA, -6L), .internal.selfref = ) library(qqman) qq(fdr2_sorted$FDR.q.val2, main = "RG_All", pch = 16, col=fdr1_sorted$group, cex = 0.8, las = 1) Please advise On Wed, Mar 11, 2020 at 11:21 PM David Winsemius wrote: > > > On 3/10/20 9:51 PM, Ana Marija wrote: > > Hello, > > > > I am making QQ plot via: > > > > library(ggman) > > qq(fdr2_sorted$FDR.q.val2, main = "RG_All", pch = 17, > > col=fdr1_sorted$group, cex = 1, las = 1) > > > I think you may be confusing the audience. There is no qq function in > the ggman package. There is however a qq function in the qqman package. > > > Running the example in help page for qqman::qq and looking at the code > suggests this is a base plot function, so the text function will allow > you to put any particular string within the plot area: > > library(qqman) > > qq(gwasResults$P) > text( 2, 6, "arbitrary") # puts text "arbitrary" at postion (x=2, y=6) > > > > > data frames used look like this: > > > >> head(fdr1_sorted) > > You should use `dput` to post reproducible data examples. > > HTH; > > David. > > > NAME GS follow > > link to MSigDB GS DETAILS SIZE ES NES NOM p-val > > 1: GO_DNA_PACKAGING_COMPLEX > > GO_DNA_PACKAGING_COMPLEX Details ... 77 0.6757226 2.466745 > > 0 > > 2: GO_PROTEIN_DNA_COMPLEX > > GO_PROTEIN_DNA_COMPLEX Details ... 132 0.5958179 2.346520 0 > > 3: GO_RESPONSE_TO_TYPE_I_INTERFERON > > GO_RESPONSE_TO_TYPE_I_INTERFERON Details ... 52 -0.7521569 -2.533148 > > 0 > > 4: GO_RESPONSE_TO_INTERFERON_GAMMA > > GO_RESPONSE_TO_INTERFERON_GAMMA Details ... 101 -0.6370415 -2.420473 > > 0 > > 5: GO_CELLULAR_RESPONSE_TO_INTERFERON_GAMMA > > GO_CELLULAR_RESPONSE_TO_INTERFERON_GAMMA Details ... 85 -0.6571892 > > -2.402153 0 > > 6: GO_GRANULOCYTE_MIGRATION > > GO_GRANULOCYTE_MIGRATION Details ... 43 -0.7332099 -2.398983 > > 0 > > FDR q-
[R] Relatively Simple Maximization Using Optim Doesnt Optimize
I am trying to familiarize myself with optim() with a relatively simple maximization. Description: L and K are two terms which are constrained to add up to a total 10 (with respective weights to each). To map this constraint I plugged K into the function (to make this as simple as possible.) Together these two feed into one nonlinear function which is the product of two monotonic (on the positive interval) functions. Then that numbers is returned in a function fed to optim, which should maximize the output by adjusting L. The whole code is: production1 <- function(L){ budget=10 Lcost=12 Kcost=15 K=(budget-L*Lcost)/Kcost machines=0.05*L^(2/3)*K^(1/3) return(machines) } # production1(6000) #example of number with much higher output vs optim result S1=optim(1001,production1,method="CG",control=list(fnscale=-1)) S1 Output: $par [1] 1006.536 $value [1] 90.54671 $counts function gradient 201 101 $convergence [1] 1 $message NULL For some reason this never explores the problem space and just spits out some answer close to the initial condition. What am I doing wrong? Thanks, Skyler S. [[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] [Rd] R 4.0.0 scheduled for April 24
Full schedule is available on developer.r-project.org. Notice that Copenhagen Business School, like all Danish educational institutions, is physically locked down for two weeks due to COVID-19. The schedule is automated, but there may be irregularities with the nightly builds, if things act up and I can't get to the machine. -- Peter Dalgaard, Professor, Center for Statistics, Copenhagen Business School Solbjerg Plads 3, 2000 Frederiksberg, Denmark Phone: (+45)38153501 Office: A 4.23 Email: pd@cbs.dk Priv: pda...@gmail.com __ r-de...@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel ___ r-annou...@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-announce __ 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.