You are on page 1of 19

Alastair Sanderson, useR!

2011
Studying galaxies in the nearby Universe,
using R and ggplot2
Alastair Sanderson
Astrophysics & Space Research Group,
University of Birminham
!!!"sr"#ham"ac"u$%&a'rs
()entaurus A( ala*y
+essier ,1 ala*y
-maes credit. Astronomy /icture 0f the 1ay

Alastair Sanderson, useR! 2011
Overview
A taste of multivariate data visualization in an
Astronomical context, demonstrating the power of
R and ggplot2!

0vervie! of distri#ution of near#y ala*ies and ala*y roups

R ideally suited to Astronomy & Astrophysics 2althouh not yet


!idely used3. wealth of multivariate public data (observed &
simulated), free from proprietor & ethical restrictions on use

1ata from hyper451A ala*y data#ase


R code snippets accompany each plot, to hihliht $ey steps
R code snippets accompany each plot, to hihliht $ey steps

Alastair Sanderson, useR! 2011
Data structure
id Riht Ascension 1eclination 6elocity 4uminosity ttype
a
a
#
#
"""

1ata frame !ith 7 columns & &100,000 ro!s8 each ro! is


a different ala*y
ddply2 A, "2id3, summari9e, sima : sd2velocity3 3
ddply2 A, "2id3, summari9e, sima : sd2velocity3 3
5*tract summary data frame of lo#al
group properties usin (plyr( pac$e, e""
;lonitude;
;latitude;
galax
group -1
morpholoical
classification

Alastair Sanderson, useR! 2011
Galaxy velocity distribution
A<deccut => cut?interval2A<dec, lenth:@03
Aplot2*:vel, data:A, eom:BhistoramB, #in!idth:100, facets: & deccut3
A<deccut => cut?interval2A<dec, lenth:@03
Aplot2*:vel, data:A, eom:BhistoramB, #in!idth:100, facets: & deccut3

6elocity 2mostly3 eAuivalent to distance distance 2Cu##le(s 4a!3

Rich in structure, !ith sinificant differences #et!een South &


Dorth hemisphere 2left%riht panels3
A fe! near#y ala*ies
movin to!ards us

Alastair Sanderson, useR! 2011
Galaxy distribution on the sky
E coord?map2pro'ection:BaitoffB3 E scale?*?continuous2trans:BreverseB3
E coord?map2pro'ection:BaitoffB3 E scale?*?continuous2trans:BreverseB3
!ast is left & "est is right!
+il$y Fay reion e*cluded
(cosmic !e#( of filaments
'longitude'
'
l
a
t
i
t
u
d
e
'
clusters & roups
of ala*ies

Alastair Sanderson, useR! 2011
Polar coordinate velocity plots

6elocity over a thin slice in declination 2(latitude(38 sho!s (peculiar


velocities( of ala*ies fallin into roups and clusters 2!hich contain
lots of dar$ matter3" Sometimes $no!n as (hoc$ey puc$( diarams"
A<deccut => cut?num#er2A<dec, n:23
Aplot2ra, vel, data:A, facets: & deccut3 E coord?polar23
A<deccut => cut?num#er2A<dec, n:23
Aplot2ra, vel, data:A, facets: & deccut3 E coord?polar23
(finer of God( G ala*ies
fallin into cluster%roup

Alastair Sanderson, useR! 2011
Galaxy morphological types
5lliptical ala*y
Spiral ala*y
-mae credit. Diel Brandt(s homepae
>7 H Cu##le stae I type G E10
A<morph => factor2cut2A<ttype, #rea$s:c2>7, 0, 103, include"lo!est:I,
la#els:c2B5arlyB, B4ateB33, e*clude:DU443
levels2A<morph3JKL => BMB
A<morph => factor2cut2A<ttype, #rea$s:c2>7, 0, 103, include"lo!est:I,
la#els:c2B5arlyB, B4ateB33, e*clude:DU443
levels2A<morph3JKL => BMB
(5AR4N(
type
(4AI5(
type
5d!in Cu##le

Alastair Sanderson, useR! 2011
issing data on morphology

Cistorams of ala*y luminosity, split #y morpholoy 2,000 = vel = 10,0003

Unclassified ala*ies 2#lue3 are mostly faint

+orpholoical classification is difficult, #ut can #e achieved throuh


(cro!dsourcin( initiatives li$e Gala*y Ooo 2!!!"ala*y9oo"or3
p H Aplot24B, data:A, eom:BhistoramB, fill:morph3 E scale?*?lo1023
p E scale?y?sArt23 p E eom?historam2position:BfillB3
p H Aplot24B, data:A, eom:BhistoramB, fill:morph3 E scale?*?lo1023
p E scale?y?sArt23 p E eom?historam2position:BfillB3

Alastair Sanderson, useR! 2011
G!"!#$ G%OUPS

Gala*ies held toether #y ravity8 adds (peculiar velocity( #ias8 close


interactions and merers #et!een ala*ies #ecome possi#le, !hich can
transform their properties

)omplete 4ocal>volume Groups Sample 2)4oGS3 selected from a


cataloue of roups identified #y (friends>of>friends( clusterin in position &
velocity space 2Garcia, 1@@K, Astronomy & Astrophysics, 100, PQ3

See http.%%!!!"sr"#ham"ac"u$%&e'os%)4oGS"html for more details 2)loGS


pro'ect run #y 5!an 0(Sullivan at U" Birminham3

Alastair Sanderson, useR! 2011
Galaxy velocities & dark matter

Gala*ies #ound #y lare mass of dar$ matter


2&10
12
R 10
1,
+
sun
3 G Gaussian velocity distri#ution

Brihtest Group 5arly>type 2BG58 dashed line3 is


(special( & usually found near roup centre
Srit9 O!ic$y, the first person
to infer the presence of dar$
matter 2in 1@KK3, from ala*y
velocities"
BG5 H su#set2su#set2G, morph::B5arlyB3, luminosity::ma*2luminosity33
E eom?vline2*intercept:BG5<vel, linetype:2, colour:B!hiteB3
BG5 H su#set2su#set2G, morph::B5arlyB3, luminosity::ma*2luminosity33
E eom?vline2*intercept:BG5<vel, linetype:2, colour:B!hiteB3
4GG KKT, a$a
DG) ,0PP Group

Alastair Sanderson, useR! 2011
'elocity distribution across a range o(
groups

)omposite of &K,00 ala*ies in T2 roups8 velocity scaled to 9ero mean


& unit 2ro#ust3 variance !ithin each roup

Similar distri#utions for each type, #ut much narro!er pea$ for brightest
group earl tpes, !hich live close to roup centre
E eom?ru2data:BG5, alpha:0"K3
E eom?ru2data:BG5, alpha:0"K3
E eom?density2alpha:0"KK3
E eom?density2alpha:0"KK3

Alastair Sanderson, useR! 2011
)uantile*+uantile plot o( velocity
distribution

Uuantile>Auantile plot to
demonstrate Gaussian 2normal3
distri#ution of ala*y velocities
!ithin roups
Aplot2*:An, y:svel, data:A3 E coord?eAual23 E
eom?a#line2intercept:0, slope:1, linetype:23
Aplot2*:An, y:svel, data:A3 E coord?eAual23 E
eom?a#line2intercept:0, slope:1, linetype:23
A => ddply2A, "2lnum3, transform, svel : scale2vel, scale:mad2vel333
A<An => AAnorm2A<svel, plot:SA4S53<*
A => ddply2A, "2lnum3, transform, svel : scale2vel, scale:mad2vel333
A<An => AAnorm2A<svel, plot:SA4S53<*
Use ro#ust sdev estimator
to suppress outlier #ias
Sorce eAual
si9e in * & y
0utliers. infallin or
interloper ala*ies

Alastair Sanderson, useR! 2011
Galaxy spatial distribution in groups

Spatial density pea$ed &


rouhly circular

BG5 2(E(3 usuall near


centre of isodensity contours

5arly>type ala*ies
preferentially found in
hihest density reions
Aplot2ra, dec, data:df, si9e:4B, colour:svel, shape:morph, alpha:0",3 E
scale?si9e2trans:Blo10B3 E eom?density2d2aes2roup:13, leend:SA4S53 E """
Aplot2ra, dec, data:df, si9e:4B, colour:svel, shape:morph, alpha:0",3 E
scale?si9e2trans:Blo10B3 E eom?density2d2aes2roup:13, leend:SA4S53 E """
4GG KKT, a$a
DG) ,0PP Group

Alastair Sanderson, useR! 2011
,*type morphology vs- radius

5arly>type ala*ies found in denser environments. (morpholog#


densit relation( 21ressler, 1@T0, Astrophys" V", 2K7, K,13

+erers & interactions transform spirals into elliptical ala*ies


(5AR4N( type
(4AI5( type
plot2data:A, aes2*:r, y:ttype, si9e:4B33 E eom?point2alpha:0",,
shape:13 E scale?si9e2trans:Blo10B3 E eom?smooth2leend:SA4S53 E
scale?*?continuous2trans:BsArtB3
plot2data:A, aes2*:r, y:ttype, si9e:4B33 E eom?point2alpha:0",,
shape:13 E scale?si9e2trans:Blo10B3 E eom?smooth2leend:SA4S53 E
scale?*?continuous2trans:BsArtB3
(ru( of unclassified ala*ies

Alastair Sanderson, useR! 2011
Dashboard o( plots

Assem#le multiple
panels for each ala*y
roup

/anel layout set usin


(rid( pac$ae

1ash#oard function
applied across all
roups usin d_ply(),
!ith a proress #ar
d?ply2 A, "2id3, /lot/anels, "proress:;te*t; 3
d?ply2 A, "2id3, /lot/anels, "proress:;te*t; 3
(/lot/anels( is the user(s
function to create the
dash#oard

Alastair Sanderson, useR! 2011
Diversity o( group properties
4GG 1QQ 4GG K@T
similar spatial
distributions, but
$%% &'' (left)
has onl & earl#
tpe galax(((

Alastair Sanderson, useR! 2011
.urther R*related reading

See the (plot2( #oo$ and the paper on the use of the
(plyr( pac$ae 2V" Stat" Soft", vol P0, issue 13, #oth #y
Cadley Fic$ham.

4eland Fil$inson(s e*cellent #oo$ (Ihe Grammar of Graphics(


is also !ell !orth readin

Alastair Sanderson, useR! 2011
Summary

Ihe local ala*y distri#ution is a hihly structured multivariate


dataset, ideally suited for analysin & visualisin !ith R and
plot2

Rouhly half of all ala*ies live in roups & clusters, #ound #y


ravity from dar$ matter, !here interactions can chane their
properties

R is a powerful tool for tac)ling ma*or unsolved problems in


Astronom & Astrophsics, especiall in the era of big data(((

Alastair Sanderson, useR! 2011
Alastair Sanderson
a'rsWstar"sr"#ham"ac"u$
!!!"sr"#ham"ac"u$%&a'rs

You might also like