---
title: "Using the PAC package"
date: "`r Sys.Date()`"
output: rmarkdown::html_vignette
bibliography: references.bib
vignette: >
  %\VignetteIndexEntry{Using the PAC package}
  %\VignetteEngine{knitr::rmarkdown}
  \usepackage[utf8]{inputenc}
---

This vignette illustrates the basic usage of the PAC package for R. 

Biology Example
---------------------------

The PAC-MAN data analysis pipeline can be applied to mass-cytometry (CyTOF) data analysis. In this case, the user reads in the example data files (already saved as the Rdata format) subsetted from Bendall et al., 2011 and goes through the data analysis pipeline.

```{r, echo=F}
set.seed(1)
```

Load the required R packages

```{r Load R packages}

library(PAC)


```

Construct the sampleIDs vector to analyze the data

```{r Load data}
sampleIDs<-c("Basal", "BCR", "IL7")

```

Partition, cluster into desired number of subpopulations, and output subpopulation mutual information networks

```{r PAC and Network Inference}
samplePass(sampleIDs, dim_subset=NULL, hyperrectangles=35, num_PACSupop=25, num_networkEdge=25, max.iter=50)
```

Multiple Alignments of Networks

```{r MAN}

clades_network_only<-MAN(sampleIDs, num_PACSupop=25, smallSubpopCutoff=100, k_clades=5)

```

Refine the PAC labels with multiple alignments of networks representative labels for clades

```{r refine PAC labels with MAN clade results}
refineSubpopulationLabels(sampleIDs,dim_subset=NULL, clades_network_only, expressionGroupClamp=5)
```

Draw clade/representative mutual information networks

```{r Clade Networks}
getRepresentativeNetworks(sampleIDs, dim_subset=NULL, SubpopSizeFilter=200, num_networkEdge=25)
```

Obtain annotations of subpopulations

```{r Annotation}
aggregateMatrix_withAnnotation<-annotateClades(sampleIDs, topHubs=4)
head(aggregateMatrix_withAnnotation)

```


Append subpopulation proportions for each sample in the annotation matrix

```{r Append subpopulation proporation for each sample}
annotationMatrix_prop<-annotationMatrix_withSubpopProp(aggregateMatrix_withAnnotation)
head(annotationMatrix_prop)
```




