Giter Club home page Giter Club logo

ggfortify's People

Contributors

aleungplants avatar aphalo avatar axjadamson avatar damirpolat avatar darios avatar darwinawardwinner avatar dereksonderegger avatar dprat avatar jonathon-love avatar kellenbrosnahan avatar lselzer avatar michaelchirico avatar raulminan avatar rekyt avatar richierocks avatar robjhyndman avatar sinhrks avatar talgalili avatar terrytangyuan avatar thomassoeiro avatar tjebo avatar yoursdearboy avatar yutannihilation avatar zexicai avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ggfortify's Issues

ENH: Retrieve original data from parent environment

There are some classes which doesn't hold original data itself, but stores a call signature when the model was created. If autoplot can retrieve original data from parent environment, we can omit the explicit data keyword.

Some standard function behave like above, but it can be an unexpected result if the original variable has been changed. Thus this behavior should be explicitly turned on by global option (or argument).

TST: Creating vignettes fails on Travis CI repeatedly

From yesterday, following error occurs on Travis CI repeatedly. Maybe any dependencies has been changed? Strangely I can't reproduce the issue on my local.

The branch is unmodified fork of current master:

* creating vignettes ... ERROR
Loading required package: proto
Loading required package: ggplot2
Warning in rgl.init(initValue, onlyNULL) :
  RGL: unable to open X11 display
Warning in fun(libname, pkgname) : Error in 'rgl_init'
Don't know how to automatically pick scale for object of type complex. Defaulting to continuous
Don't know how to automatically pick scale for object of type complex. Defaulting to continuous
Quitting from lines 112-121 (plot_pca.Rmd) 
Error: processing vignette 'plot_pca.Rmd' failed with diagnostics:
Discrete value supplied to continuous scale
Execution halted

The error message says it is related to lfda block.

library(lfda)

# Local Fisher Discriminant Analysis (LFDA)
model <- lfda(iris[-5], iris[, 5], 4, metric="plain")
autoplot(model, data = iris, frame = TRUE, frame.colour = 'Species')

# Kernel Local Fisher Discriminant Analysis (KLFDA)
model <- klfda(kmatrixGauss(iris[-5]), iris[, 5], 4, metric="plain")
autoplot(model, data = iris, frame = TRUE, frame.colour = 'Species')

Change Legend Title

Hi
How can I change the title of the legend? Right now it is always called strata

I tried scale_color_discrete(name = xlab) but then I got 2 legend:

image

Error on loading ggfortify

Hi

I'm trying to plot acf outputs with ggplot2, and trying to use ggfortify, but get the error below.

Best,
Richard

library(ggplot2)
library(ggfortify)
Loading required package: scales
Error in unloadNamespace(package) :
namespace ‘scales’ is imported by ‘ggplot2’ so cannot be unloaded
Error in library(pkg, character.only = TRUE, logical.return = TRUE, lib.loc = lib.loc) :
Package ‘scales’ version 0.2.4 cannot be unloaded

Using R on Ubuntu Trusty: R: 3.2.0-4trusty0

The next version of forecast conflicts with ggfortify

As Hadley tweeted, forecast package will natively support ggplot2. That's a great news per se, but this means that they implemented their own fortify and autoplot methods, which conflict with ones in ggfortify package.

dplyr::intersect(ls(asNamespace('ggfortify')), ls(asNamespace('forecast')))
#> [1] "autoplot.acf"           "autoplot.Arima"         "autoplot.decomposed.ts" "autoplot.ets"           "autoplot.forecast"     
#> [6] "autoplot.stl"           "autoplot.ts"            "fortify.forecast"       "fortify.ts"  

I tried the dev version of forecast package and found the error (Sorry, I haven't dig into the detail yet... Please forgive me to just drop the console log here.):

library(ggplot2)
library(forecast)

# no problem here
ggplot(AirPassengers, aes(x, y)) + geom_forecast()

library(ggfortify)
#> Loading required package: proto

# fail!
ggplot(AirPassengers, aes(x, y)) + geom_forecast()
#> Error in eval(expr, envir, enclos) : object 'x' not found

Session info:

devtools::session_info()
#> Session info --------------------------------------------------------------------------------------------------------------------------
#>  setting  value                       
#>  version  R version 3.2.3 (2015-12-10)
#>  system   x86_64, linux-gnu           
#>  ui       RStudio (0.99.878)          
#>  language (EN)                        
#>  collate  en_US.UTF-8                 
#>  tz       <NA>                        
#>  date     2016-02-18                  
#> 
#> Packages ------------------------------------------------------------------------------------------------------------------------------
#>  package    * version    date       source                               
#>  assertthat   0.1        2013-12-06 CRAN (R 3.2.2)                       
#>  colorspace   1.2-6      2015-03-11 CRAN (R 3.2.2)                       
#>  DBI          0.3.1      2014-09-24 CRAN (R 3.2.2)                       
#>  devtools     1.10.0     2016-01-23 CRAN (R 3.2.3)                       
#>  digest       0.6.9      2016-01-08 CRAN (R 3.2.3)                       
#>  dplyr        0.4.3.9000 2015-10-01 Github (hadley/dplyr@dd10ccd)        
#>  forecast   * 7.0        2016-02-18 Github (robjhyndman/forecast@451cb34)
#>  fracdiff     1.4-2      2012-12-02 CRAN (R 3.2.2)                       
#>  ggfortify  * 0.1.0      2015-11-30 CRAN (R 3.2.3)                       
#>  ggplot2    * 2.0.0      2015-12-18 CRAN (R 3.2.2)                       
#>  gridExtra    2.0.0      2015-07-14 CRAN (R 3.2.2)                       
#>  gtable       0.1.2      2012-12-05 CRAN (R 3.0.0)                       
#>  labeling     0.3        2014-08-23 CRAN (R 3.2.2)                       
#>  lattice      0.20-33    2015-07-14 CRAN (R 3.2.1)                       
#>  magrittr     1.5        2014-11-22 CRAN (R 3.2.2)                       
#>  memoise      1.0.0      2016-01-29 CRAN (R 3.2.3)                       
#>  munsell      0.4.3      2016-02-13 CRAN (R 3.2.3)                       
#>  nnet         7.3-12     2016-02-02 CRAN (R 3.2.3)                       
#>  plyr         1.8.3      2015-06-12 CRAN (R 3.2.2)                       
#>  proto      * 0.3-10     2012-12-22 CRAN (R 3.0.0)                       
#>  quadprog     1.5-5      2013-04-17 CRAN (R 3.2.2)                       
#>  R6           2.1.2      2016-01-26 CRAN (R 3.2.3)                       
#>  Rcpp         0.12.3     2016-01-10 CRAN (R 3.2.3)                       
#>  scales       0.3.0.9000 2015-09-21 Github (hadley/scales@7fc502c)       
#>  tidyr        0.4.1      2016-02-05 CRAN (R 3.2.3)                       
#>  timeDate   * 3012.100   2015-01-23 CRAN (R 3.2.2)                       
#>  tseries      0.10-34    2015-02-20 CRAN (R 3.2.2)                       
#>  zoo        * 1.7-12     2015-03-16 CRAN (R 3.2.2)  

fortify for `raster::raster` objects

Hey,
Thanks for building this awesome package that helps working with ggplot2 in all circumstances ;)

There are quite a number of methods for sp objects in ggfortify but none for raster objects.
The rasterVis package include a fortify()-like function in its function gplot() .
I was thinking of implementing something similar in ggfortify.

Submit to CRAN

  • Once tag & release current master as v0.0.1
  • Revise doc descriptions and formats
  • Change fortify and autoplot argnames to be compat with {ggplot2}
    • Confirm all the current examples work with warning after the change
    • Create test_compat and move previous examples.
    • Change all the examples to use new argnames
  • Release pre0.0.2 and submit it to CRAN
    • ftp://cran.r-project.org/incoming/
  • Fix indicated points and resubmit (#23)
  • Fix indicated points and resubmit (#25)

survfit error on plot

Hi,

please, when i try to run

library(ggfortify)
library(survival)
fit <- survfit(Surv(time, status) ~ sex, data = lung)
autoplot(fit)

gave this error:
Error: GeomConfint was built with an incompatible version of ggproto.
Please reinstall the package that provides this extension.

thank you so much

API: Consider return values for grid.arrange

There are few plotting functions using grieExtra::grid.arrange internally, such as autoplot.lm. These function doesn't have return value, thus we cannot decorate it later.

Consider a better way to allow decoration.

ENH/CLN: Integration with {broom}

Utilize {broom} as much if outputs data.frame which has enough information for plotting.

  • aareg_tidiers
  • anova_tidiers
  • cch_tidiers
  • confint_tidy
  • coxph_tidiers
  • cv.glmnet_tidiers
  • felm_tidiers
  • gam_tidiers
  • glmnet_tidiers
  • lme4_tidiers
  • multcomp_tidiers
  • nls_tidiers
  • pyears_tidiers
  • ridgelm_tidiers
  • rlm_tidiers
  • sexpfit_tidiers
  • smooth.spline_tidiers
  • sp_tidiers
  • survfit_tidiers
  • survreg_tidiers
  • tidy.manova
  • tidy.map
  • tidy.TukeyHSD
Affects to backward compat

autoplot should not be affected. Column names output from fortify may be affected.

  • kmeans_tidiers
  • tidy.density
  • tidy.spec
Unable to use
  • tidy.ts: Doesn't preserve timestamps.
  • Arima_tidiers: Not usable for autoplot.
  • glm_tidiers: fortify is already defined in {ggplot2}. Considering to use autoplot internally for simplification.
  • lm_tidiers: Same as glm.
  • htest_tidiers: Plotting single test result is not very useful. Reconsider if there is good example.
  • tidy.pairwise.htest: Doesn't contain confidence intervals. Considering to use {pairwiseCI}
  • tidy.ftable: No need to use, simply call as.data.frame.

Order of Groups is Undesirably Rearranged

I have a survival grouping where the factor levels are different to alphabetical ordering.

levels(samplesGroups)
[1] "Low"  "High"

survfit keeps these in the correct order

> survivalFit
Call: survfit(formula = survivalData ~ samplesGroups)

	            n events median 0.95LCL 0.95UCL
samplesGroups=Low  17     11   3.63   1.838      NA
samplesGroups=High 17     10   4.55   0.992      NA

However, autoplot always places High first and Low second in the legend, because it ignores the ordering and just rearranges everything alphabetically. This should not happen.

Merging legends

Looks possible but can't work well with current ggmultiplot as legend must be considered as plot (grob). Needs separated class to dot this, or logic to merge the same legends when output.

p <- autoplot(lm(Petal.Width ~ Petal.Length, data = iris), colour = 'Species', data = iris)

grob <- ggplotGrob(p@plots[[1]])
leg <- grob$grobs[[which(grob$layout$name == "guide-box")]]

plots <- lapply(p@plots, function(x) x + theme(legend.position = 'none'))
plots[[5]] <- leg

layout_matrix = rbind(c(1, 2, 5), c(3, 4, 5))
do.call(grid.arrange, c(plots, list(ncol = 3, layout_matrix = layout_matrix))

rplot

Adding Line Colour Changes Line Position

I firstly used the command

survivalPlot <- autoplot(survivalFit, conf.int = FALSE)

and got a sensible looking plot.

normalsurv

Then, I added a line colour and the placement of lines changed

autoplot(survivalFit, conf.int = FALSE, surv.colour = "red")

badsurv

The legend also disappeared.

Support lda {MASS}

Hola,

Is it possible to use lda {MASS}? Can you please provide an example?

Thanks

Using themes

Hi,
Love the package.

Maybe I'm just being stupid but can I use themes like I would in typical ggplot?

I'd hope
autoplot(lm(rnorm(10)~rnorm(10, 2))) +
theme_bw()

would theme the 4 facets with the black and white theme. This syntax works for autoplot in other cases (e.g. microbenchmark).

Survival Plot Doesn't Allow Per-Group Aesthetics

Unlike the base survival plot, it's not possible with ggfortify to set a different line colour for each patient group. Looking at the documentation of autoplot.survfit, it's only possible to choose a single colour for the parameter surv.colour.

ggsave doesn't recognize ggfortity objects

plotdiag <-autoplot(result, which=c(1:3,5), mfrow=c(2,2))
plotdiag

***partdiage;

ggsave(plot=plotdiag, file='cuckoo-R-diag.png', h=4, w=6, units="in", dpi=300)

returns
Error in UseMethod("grid.draw") :
no applicable method for 'grid.draw' applied to an object of class "ggmultiplot"

I think Wickham modifies ggsave() to accept gtable objects. Do you create such an object? Perhaps add that as a class as well?

Using ggfortify 0.1.0 and ggplot 2.0.0

NEWS File Not Visible on CRAN

Many packages have a NEWS or README file with links on their CRAN webpage. ggfortify uses an unusual file format for these, so these files are not visible to the end user. Also, the NEWS file is missing information about what's new in the 0.3 version.

Error from dplyr exported objects.

I'm trying to use autoplot on glm and lm objects. I am getting errors about dplyr exported objects.

> autoplot(lm(c(1:10)~ rnorm(10)))
Error: 'arrange_' is not an exported object from 'namespace:dplyr'

I tried to reinstall ggfortify from github and got
Error: processing vignette 'basics.Rmd' failed with diagnostics:
'select_' is not an exported object from 'namespace:dplyr'

Has something changed in dplyr that means these functions are broken? Thanks in advance for any help.

My sessionInfo is
R version 3.1.1 (2014-07-10)
Platform: x86_64-pc-linux-gnu (64-bit)

locale:
[1] LC_CTYPE=en_GB.UTF-8 LC_NUMERIC=C
[3] LC_TIME=en_GB.UTF-8 LC_COLLATE=en_GB.UTF-8
[5] LC_MONETARY=en_GB.UTF-8 LC_MESSAGES=en_GB.UTF-8
[7] LC_PAPER=en_GB.UTF-8 LC_NAME=C
[9] LC_ADDRESS=C LC_TELEPHONE=C
[11] LC_MEASUREMENT=en_GB.UTF-8 LC_IDENTIFICATION=C

attached base packages:
[1] tcltk stats graphics grDevices utils datasets methods
[8] base

other attached packages:
[1] ggfortify_0.0.1 dplyr_0.2 sqldf_0.4-10 RSQLite_1.0.0
[5] DBI_0.3.1 gsubfn_0.6-6 proto_0.3-10 readxl_0.1.0
[9] ggplot2_1.0.0

DOC: Migrate rpubs to vignette

  • Prepare more vignette merging existing RPubs docs
  • Release next version (Dec, 2015 or Jan, 2016 following CRAN policy?)
  • Add link to vignette from existing RPubs.
  • Rename VignetteIndexEntry

Cleanup internals

  • Make post_fortify to always attach base_class
  • Move ggplot instanciation to geom_factory, do not include duplicated data to geom.

Variable Name in Survival Plot Legends

By default, autoplot uses the names from survivalFit[["strata"]] as the legend levels. They have a variableName=value format. Programmer's variable names are not something that a figure to be published in a medical journal should have displayed. Perhaps autoplot should use code like gsub(".*=", '', strataNames) to place only the level name in the legend. autoplot also lacks any legend customisation options, such as the legend title.

importing autoplot

Dear Sir,
I have written a function in which I used ggfortify to plot PCA the overall function is pretty simple, see below.
When I do the package (https://github.com/kendomaniac/docker4seq) check I get the following warning:
samplesPca: no visible global function definition for ‘autoplot’
Undefined global functions or variables:
autoplot

I import in my function ggfortify, but it seems that the autoplot in not imported from ggfortify
Could please suggest a way of fix this problem?
Cheers
Raf

######################################
#' @title Sample PCA on raw counts
#' @description This function runs PCA via ggfortify and ggplot2 on the output of samples2experiments function
#'
#' @param data, the counts dataframe generated by samples2experiemtn function
#' @param groups, a character string indicating association between samples and experimental groups
#' @param label, a boolean value, TRUE or FALSE to ad the names of the samples in the plot
#' @param label.size, an integer value indicating the size of label
#' @param output.file, a tab delimited file in which the first column are names from counts object from experiment.table.Rda file generated with samples2experiment function. In the pdf will be also rpesent the istigram fo the PCA variance dispersion.
#' @import ggfortify
#' @importFrom graphics plot
#' @importFrom grDevices pdf
#' @importFrom grDevices dev.off
#' @importFrom stats prcomp
#' @return a pdf file with the PCA plot
#' @examples
#'\dontrun{
#' load("test_experiment.tables.Rda")
#' samplesPca(data=counts, groups=c("d","eb","wb","ws"), label = TRUE, label.size = 3)
#' output.file="test.pdf", label = FALSE, label.size = 3)
#' }
#' @export
samplesPca <- function(data, groups=NULL, output.file=NULL, label, label.size){
if(!is.null(groups)){
data.df <- data.frame(names(data), as.factor(groups))
names(data.df) <- c("samples","groups")
if(is.null(output.file)){
autoplot.prcomp(prcomp(t(data)), data=data.df, colour='groups', label = label, label.size = label.size)
}else{
pdf(output.file)
plot(prcomp(t(data)), main="")
autoplot(prcomp(t(data)), data=data.df, colour='groups', label = label, label.size = label.size)
dev.off()
cat(paste("\nPCA is saved in ",output.file, sep=""))
}
}else{
if(is.null(output.file)){
autoplot(prcomp(t(data)))
}else{
pdf(output.file)
plot(prcomp(t(data)), main="")
autoplot(prcomp(t(data)))
dev.off()
cat(paste("\nPCA is saved in ",output.file, sep=""))
}
}
return(data.df)
}

Strange Handling of Colouring By Variable in Current Environment

The legend is missing.

species <- as.numeric(factor(iris[, "Species"]))
autoplot(prcomp(iris[, 1:4]), colour = species, environment = environment())
Warning message:
In if (value %in% columns) { :
  the condition has length > 1 and only the first element will be used

Picking a column from the data frame works without a problem.

autoplot(prcomp(iris[, 1:4]), data = iris, colour = "Species") # Legend shown.

How to add different point type for kmeans plot?

for example:

d <- rnorm(100)
i <- c(rep("A",50),rep("B",50))
fit <- kmeans(d,2,nstart=1000)
mds <- cmdscale(dist(d))
ggplot(as.data.frame(mds)) + geom_point(aes(mds[,1],mds[,2],shape=i),size=3)

So, I don't know how to use "i" by autoplot for different point...shape in autoplot is a logical value.

autoplot fails on poly regression

Hi,

I get similar error message as in #137 when doing any polynomial regression.
Please see reproducible example:

library(ggfortify)
model <- lm(mpg ~ poly(hp, 2, raw = TRUE),data = mtcars)
autoplot(model)
Error: Each variable must be a 1d atomic vector or list.
Problem variables: 'poly(hp, 2, raw = TRUE)'

par(mfrow = c(2,2))
plot(model)

autoplot for glm() does not work with two column response variable

binomial glm() models are often fit with a two column response variable. autoplot for these models is failing. Here is a reproducible example.

library(ggfortify)
data(menarche)
glm.out <- glm(cbind(Menarche, Total-Menarche) ~ Age, family=binomial(logit), data=menarche)
autoplot(glm.out) # fails 
#Error: Each variable must be a 1d atomic vector or list. 
#Problem variables: 'cbind(Menarche, Total - Menarche)'

# works fine
par(mfrow = c(2,2))
plot(glm.out)

Package got removed from the CRAN

https://cran.r-project.org/web/packages/ggfortify/index.html shows:

Package ‘ggfortify’ was removed from the CRAN repository.

Formerly available versions can be obtained from the archive.

Archived on 2016-05-02 as check problems were not corrected despite reminders.

> install.packages fails as expected; however, the devtools install continues to work as expected after:

library(devtools)
install_github('sinhrks/ggfortify')

Plot different choice of principal components axes

Hello, thank you for the package. I find it really usefull. However, I would like the option to plot other axes instead of just the first two. Looking at the code I see that this is hardcoded. I could make a PR change that as an option if that's ok.

ENH: Add ggbiplot

Should have the same interface with stats:::biplot.default.

Then refactor autoplot.pca_common.

Feature Request

Hello,

First and foremost, I would like to thank you and congratulate you on the effort you have put into this project. I was playing with the gglagplot function, when i noticed that it doesn't take a parameters to label the axis (y-axis - now get a "Data" label).

I was wondering if you can edit the list parameters, to accept ... (ellipsis), so that the parameters can be passed to ggplot function.

Thanks

COMPAT: Test failure in CRAN

Received kind email from CRAN:

Presumably from an update of one of

1 changepoint 2015-11-09
2 timeSeries 2015-11-09

we now see your package fail its tests with

checking tests ... ERROR
Running the tests in ‘tests/test-all.R’ failed.
Last 13 lines of output:
3: In princomp.default(df, center = TRUE, scale = FALSE) :
extra arguments 'center', 'scale' will be disregarded
4: In princomp.default(df, center = FALSE, scale = FALSE) :
extra arguments 'center', 'scale' will be disregarded
5: In princomp.default(USArrests, center = TRUE, scale = TRUE) :
extra arguments 'center', 'scale' will be disregarded
6: In princomp.default(USArrests, center = FALSE, scale = TRUE) :
extra arguments 'center', 'scale' will be disregarded
7: In princomp.default(USArrests, center = TRUE, scale = FALSE) :
extra arguments 'center', 'scale' will be disregarded
8: In princomp.default(USArrests, center = FALSE, scale = FALSE) :
extra arguments 'center', 'scale' will be disregarded
Execution halted

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.