-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
de586fd
commit b75293d
Showing
48 changed files
with
25,519 additions
and
15 deletions.
There are no files selected for viewing
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,7 @@ Date: 2014-08-20 | |
Author: Rafael S. de Souza, Alberto Krone-Martins, Jonathan Elliott, Joseph | ||
Hilbe | ||
Maintainer: Rafael S. de Souza <[email protected]> | ||
Description: User-friendly interfaces to perform fast and reliable photometric | ||
Description: User-friendly interfaces to perform fast and reliable photometric | ||
redshift estimation. The code makes use of generalized linear models and | ||
can adopt gamma or inverse gaussian families, either from a frequentist or | ||
a Bayesian perspective. The code additionally provides a Shiny application | ||
|
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes.
File renamed without changes
File renamed without changes.
2 changes: 1 addition & 1 deletion
2
R/man/glmPredictPhotoZ.Rd → R/CosmoPhotoz/man/glmPredictPhotoZ.Rd
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
### The Cosmostatistics Initiative: COIN | ||
|
||
|
||
The COsmostatistics INitiative ([COIN](https://asaip.psu.edu/organizations/iaa/iaa-working-grou | ||
-of-cosmostatistics)), a working group built within the International Astrostatistics Association | ||
([IAA](https://asaip.psu.edu/organizations/iaa/international-astrostatistics-association-overvie | ||
)), aims to create a friendly environment where hands-on collaboration between astronomers, | ||
cosmologists, statisticians and machine learning experts can flourish. COIN is designed to | ||
promote the development of a new family of tools for data exploration in cosmology. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
### R package CosmoPhotoz | ||
Copyright (C) 2014 COIN | ||
|
||
This program is free software: you can redistribute it and/or modify | ||
it under the terms of the GNU General Public License version 3 as published by | ||
the Free Software Foundation. | ||
|
||
This program is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
GNU General Public License for more details. | ||
|
||
A copy of the GNU General Public License is available at | ||
http://www.r-project.org/Licenses/ | ||
|
||
##### Authors: | ||
Rafael S. de Souza (ELTE), Alberto Krone-Martins (University of Lisbon), Jonathan Elliott (MPE), Ewan Cameron (Oxford), Emille E. O. Ishida (MPA), Joseph Hilbe (ASU) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
Version: 1.0 | ||
|
||
RestoreWorkspace: Default | ||
SaveWorkspace: Default | ||
AlwaysSaveHistory: Default | ||
|
||
EnableCodeIndexing: Yes | ||
UseSpacesForTab: Yes | ||
NumSpacesForTab: 2 | ||
Encoding: UTF-8 | ||
|
||
RnwWeave: knitr | ||
LaTeX: pdfLaTeX |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
|
||
Shiny CosmoPhotoz application | ||
|
||
This is a shiny application to run the photometric redshift estimation code. | ||
|
||
To run the application locally in your own machine, you just need to do: | ||
|
||
library(shiny) | ||
runApp(paste(find.package("CosmoPhotoz"),"/glmPhotoZ-2/",sep="")) | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
|
||
Welcome to the CosmoPhotoz - GLM PhotoZ estimation Shiny interface! | ||
|
||
This interface provides a simple control for the R version of the CosmoPhotoz code. Beyond offering the control of the most used functionalities of the code, this interface provides graphical overviews of the results for diagnostics of the method (each tab is a different graphical representation of the analysis result). | ||
|
||
#### Data Input | ||
|
||
It is possible to select two types of data for analysis: | ||
* either the internal PHAT0 dataset (Hildebrandt et al. 2010); | ||
* or you can upload your own data. | ||
|
||
Note that uploaded data must be a pure text file, with each entry separated by a comma (,) and containing a header. It may contain an arbitrary number of photometric bands (the column names are not important) and one column named `redshift`. This `redshift` column is mandatory for the training data, but it is not mandatory for the data used to estimate the redshift (in case it is not provided, however, no plots will be produced, but you can still download the resulting photometric redshift estimation). | ||
|
||
Example of a file with photometric data from SDSS and spectroscopic redshifts: | ||
|
||
```{r} | ||
dered_u,dered_g,dered_r,dered_i,dered_z,redshift | ||
20.30279,18.00114,16.80232,16.3375,15.99679,0.1606594 | ||
21.42244,20.27178,18.7326,18.13726,17.82471,0.2577918 | ||
22.47656,21.32556,20.38654,19.55709,19.20674,0.6040326 | ||
18.89463,17.87326,17.23221,16.89447,16.6657,0.1681648 | ||
... | ||
``` | ||
|
||
#### Controls and options | ||
|
||
The user can select if robust PCA should be used or not. Note that the adoption of robust PCA can slow down the code considerably. The user can also select the number of principal components to consider in the GLM analysis. | ||
|
||
The number of points used for the creation of the predicted versus observed diagnostic plot (at the Prediction tab) can also be selected by the user for speeding up the plot generation. The default value is 5000; if the user select 0, all the points in the test dataset will be adopted. This value must be setted **before** launching the analysis. | ||
|
||
The method adopted for the fitting can be selected among a frequentist approach (using the R function `glm`) and a bayesian approach (using the R function `bayesglm`). The link function to be used in the model can also be selected among the gamma function and the inverse gaussian function. | ||
|
||
To run the photometric redshift estimate, the user must click in the "Run estimation" blue button. And after the estimate is ready, the redshifts can be downloaded to the user machine by clicking in the "Download photoZ results" button. | ||
|
||
#### Outputs | ||
|
||
Four different types of plots are provided by the system. Note that the prediction versus observed density plot (at the Prediction tab) may take some moments to render or update. The user can choose to use less points, which are randomly selected from the results, to create this plot if in a hurry. | ||
|
||
### References | ||
|
||
#### Associated paper | ||
**The Overlooked Potential of Generalized Linear Models in Astronomy-II: Gamma regression and photometric redshifts** | ||
Elliott, J.; de Souza, R. S.; Krone-Martins, A.; Cameron, E.; Ishida, E. E. O.; Hilbe, J., | ||
[arXiv:1409.7699](http://adsabs.harvard.edu/abs/2014arXiv1409.7699E) | ||
|
||
|
||
**CosmoPhotoz: Photometric redshift estimation using generalized linear models** | ||
##### R package | ||
[http://CRAN.R-project.org/package=CosmoPhotoz](http://CRAN.R-project.org/package=CosmoPhotoz) | ||
Rafael S. de Souza, Alberto Krone-Martins, Jonathan Elliott and Joseph Hilbe (2014). | ||
|
||
##### Shiny package | ||
[https://cosmostatisticsinitiative.shinyapps.io/CosmoPhotoz/](https://cosmostatisticsinitiative.shinyapps.io/CosmoPhotoz/) | ||
Alberto Krone-Martins; Rafael S. de Souza; Jonathan Elliott, Ishida, E. E. O.; and Joseph Hilbe (2014). | ||
|
||
|
||
##### Python package | ||
[http://cosmophotoz.readthedocs.org/en/latest/index.html](http://cosmophotoz.readthedocs.org/en/latest/index.html) | ||
J. Elliott, R. S. de Souza, A. Krone-Martins | ||
|
||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,136 @@ | ||
# R package CosmoPhotoz file inst/glmPhotoZ-2/server.R | ||
# Copyright (C) 2014 COIN | ||
# | ||
#This program is free software: you can redistribute it and/or modify | ||
#it under the terms of the GNU General Public License version 3 as published by | ||
#the Free Software Foundation. | ||
|
||
#This program is distributed in the hope that it will be useful, | ||
#but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
#GNU General Public License for more details. | ||
|
||
# A copy of the GNU General Public License is available at | ||
# http://www.r-project.org/Licenses/ | ||
# | ||
|
||
library(shiny) | ||
library(CosmoPhotoz) | ||
library(ggplot2) | ||
library(ggthemes) | ||
library(shinyIncubator) | ||
options(shiny.maxRequestSize=100*1024^2) # This is to change the maximum size of the upload to 30 MB | ||
|
||
shinyServer(function(input, output) { | ||
|
||
# Now, we need to create the reactive container | ||
shinyCompPhotoZ <- reactive({ | ||
# First we need to have some data, of course! | ||
if(input$dataSourceFlag == FALSE) { | ||
# First the file used for training | ||
inFile1 <- input$file1 | ||
if (is.null(inFile1)) { | ||
return(NULL) | ||
} | ||
# Then the file used for estimating | ||
inFile2 <- input$file2 | ||
if (is.null(inFile2)) { | ||
return(NULL) | ||
#return("\n GLM PhotoZ Estimator :: No file was uploaded for redshift estimation! ") | ||
} | ||
# Now read the files | ||
PHAT0train <- read.table(file=inFile1$datapath, sep=",", header=TRUE) | ||
PHAT0test <- read.table(file=inFile2$datapath, sep=",", header=TRUE) | ||
} else { | ||
# In this case, just lazy load the data from inside the package | ||
data(PHAT0train) | ||
data(PHAT0test) | ||
} | ||
|
||
# Some basic checking to make sure that the user will not enter values that could | ||
# cause problems via the user interface. | ||
if(is.na(input$numberOfPcs)) { | ||
return(NULL) | ||
} | ||
if(is.na(input$numberOfPoints)) { | ||
return(NULL) | ||
} | ||
nPc <- input$numberOfPcs | ||
if (nPc > (ncol(PHAT0train)-1)) { | ||
nPc <- (ncol(PHAT0train)-1) | ||
} | ||
if (nPc <= 0) { | ||
return(NULL) | ||
} | ||
if (input$numberOfPoints <= 0) { | ||
return(NULL) | ||
} | ||
|
||
# Photo-z estimation | ||
photoz <- CosmoPhotoZestimator(trainData=PHAT0train, testData=PHAT0test, | ||
numberOfPcs=nPc, method=input$method, | ||
family=input$family, robust=input$useRobustPCA) | ||
|
||
if("redshift" %in% names(PHAT0test)) { | ||
specz <- PHAT0test$redshift | ||
} else { | ||
specz <- NULL | ||
} | ||
|
||
# Time to return the data! | ||
return(data.frame(photoz, specz)) | ||
}) | ||
|
||
# Create the output text | ||
output$diagnostics <- renderPrint({ | ||
tempObj <- shinyCompPhotoZ() | ||
if(!is.null(tempObj)) { | ||
computeDiagPhotoZ(tempObj$photoz, tempObj$specz) | ||
} | ||
}) | ||
|
||
# Create basic comparison plots | ||
output$errorDistPlot <- renderPlot({ | ||
tempObj <- shinyCompPhotoZ() | ||
if(!is.null(tempObj)) { | ||
plotDiagPhotoZ(tempObj$photoz, tempObj$specz, type = "errordist") | ||
} | ||
}) | ||
output$predictObs <- renderPlot({ | ||
tempObj <- shinyCompPhotoZ() | ||
if(!is.null(tempObj)) { | ||
|
||
nPointsToUse <- input$numberOfPoints | ||
|
||
if(nPointsToUse > length(tempObj$specz)){ | ||
nPointsToUse <- length(tempObj$specz) | ||
} | ||
|
||
plotDiagPhotoZ(tempObj$photoz, tempObj$specz, type = "predobs", npoints=nPointsToUse) | ||
} | ||
}) | ||
output$violins <- renderPlot({ | ||
tempObj <- shinyCompPhotoZ() | ||
if(!is.null(tempObj)) { | ||
plotDiagPhotoZ(tempObj$photoz, tempObj$specz, type = "errorviolins") | ||
} | ||
}) | ||
output$box <- renderPlot({ | ||
tempObj <- shinyCompPhotoZ() | ||
if(!is.null(tempObj)) { | ||
plotDiagPhotoZ(tempObj$photoz, tempObj$specz, type = "box") | ||
} | ||
}) | ||
|
||
# Download the data | ||
output$downloadData <- downloadHandler( | ||
filename = function() { "glmPhotoZresults.dat" }, | ||
content = function(file) { | ||
tempObj <- shinyCompPhotoZ() | ||
if(!is.null(tempObj)) { | ||
write.table(tempObj$photoz, file, quote=F, sep=" ", col.names = FALSE, row.names = FALSE) | ||
} | ||
} | ||
) | ||
|
||
}) |
4 changes: 4 additions & 0 deletions
4
R/CosmoPhotoz_shiny/shinyapps/cosmostatisticsinitiative/CosmoPhotoz.dcf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
name: CosmoPhotoz | ||
account: cosmostatisticsinitiative | ||
bundleId: 76527 | ||
url: http://cosmostatisticsinitiative.shinyapps.io/CosmoPhotoz |
4 changes: 4 additions & 0 deletions
4
R/CosmoPhotoz_shiny/shinyapps/cosmostatisticsinitiative/CosmoPhotoz_shiny.dcf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
name: CosmoPhotoz_shiny | ||
account: cosmostatisticsinitiative | ||
bundleId: 76495 | ||
url: http://cosmostatisticsinitiative.shinyapps.io/CosmoPhotoz_shiny |
Oops, something went wrong.