BACKGROUND
regulatory variants that alter gene expression can be examined, based on allelic imbalance , i.e., alleles can be differently expressed in an individual if the regulatory region around a gene differs.
in rna sequencing data, it is possible to determine the allele from which a specific read originates when there is at least one heterozygous snp in the sequence read  <cit> .
an ai event indicates that there is a variant that changes gene expression within or near that gene.
it only takes one individual, assuming that there is a heterozygous site in the gene of interest.
the detection of an ai event is not trivial, comprising several steps, including library preparation  <cit> , sequencing  <cit> , mapping  <cit> , and analysis of somatic mutations and rna-editing  <cit> , which can bias the allele count.
to counter such biases when determining the true ai for an exon or gene, a smaller region must be visualized to discover inconsistent patterns.
the allelicimbalance package was developed to address these issues, allowing the user to test ai at a single gene or snp quickly.
nevertheless, the package is suitable for performing any custom global ai analysis, because there is always a counting step and the need to store counts in a smart container, which facilitates access to custom requests from the user.
for genes that have more than one heterozygous snp and at least one sample, there is a function to visualize ai consistency easily over the gene as an internal validation to select snps that are suitable for further ai qtl study .
the package is easy to use, comprising an infrastructure that is linked to the bioconductor environment, and allows the user to pose genetic questions quickly.fig.
<dig> short title: ai consistency using glocationplot.
detailed legend: on top are the fractions of alleles over apob for snps with a maf >  <dig> .
each bar represents one of eight samples, and the grey lines in the middle show the snp locations in apob beneath in yellow.
all snps shown are close around the black line, denoting 1: <dig> expression of the alleles.
see additional file  <dig> for the total allele count for each snp
allelicimbalance was developed to provide usability for inexperienced as experienced r-users.
for inexperienced users, there is a standard protocol to create an aseset from bam files, and functions, such as barplot, can be used directly on that aseset class object; experienced users can customize nearly any part of the workflow.
the design is based on rna-sequencing, but allelicimbalance can be used with any allele that is focused on a count-based technique, such as digital qpcr  <cit> .
implementation
management
aseset is a new object class that summarizes sequencing data .
it contains allele counts, phenotypes, and snp positions and inherits the summarizedexperiments class and all functions that can be applied to that class, such as subset and range operation  <cit> .
the class has support for strand- and nonstrand-specific data.
the first step in ai analysis is to create an aseset from mapped data in bam file format and a set of snps of interest .
the support functions will summarize the allele counts for each snp rapidly and save them in an aseset object.fig.
<dig> short title: flowchart of a typical workflow in the allelicimbalance package
fig.
<dig> short title: a few simple commands are needed to construct an aseset-class object.
detailed legend: if the bam files are unprocessed before being imported into r, we recommend elaborating the filtering on the mapping with regard to quality and perfect mate-pairs before counting the alleles
detection
equal amounts of reads are expected from two alleles, but one allele might be read more than the other by chance.
a greater number of reads improves the estimate of the total distribution.
statistical tests, such as the chi-square and binomial tests, generate the probability that an observed difference is due to this sampling bias.
these relatively simple and general tests can be applied directly to aseset objects and return a matrix with p-values for each snp and sample.
the user can easily apply other custom tests by taking advantage of the aseset accessor methods to retrieve allele fractions or counts, for example.
visualization and annotation
allelicimbalance has good visualization capabilities and provides a rich description of allele-specific expression in a region.
the barplot function  has options to display the data as a fraction or count plot and can be used with the bioconductor annotationdbi and genomicfeatures packages to show the annotation of a gene, an exon, and transcript information  <cit> .fig.
<dig> short title: the dual-strand barplot.
detailed legend: the barplot from the allelicimbalance package shows the number of reads aligning to each allele and strand for one snp.
upward bars indicate the  strand, and downward bars indicate the  strand.
the numbers under the bars are the p-values from testing whether a difference in allele expression is due to chance.
because the data are strand-specific, nearly all reads over this snp are mapped to one strand, consistent with the location of the investigated genes.
all samples in this figure are from liver.
a of the heterozygote individuals 5– <dig>   <dig> and  <dig> show no ai, whereas individual  <dig> shows significant ai.
but, the plot also shows expression off of the opposite strand, which might comprise antisense transcripts.
b individuals  <dig>   <dig>  and  <dig> show ai.
c individuals  <dig>   <dig>  and  <dig> show strong ai.
d individuals  <dig> and  <dig> show ai, whereas subjects  <dig>   <dig>   <dig>  and  <dig> show no ai.
see additional file  <dig> and  <dig> for barplots using different aligners
the bioconductor package gviz  <cit>  uses tracks and trellis graphics to imitate genome browsers’ visualization of a genomic region  <cit> .
to integrate allelicimbalance data as a track, it takes merely a function call over an aseset object to create an object that is directly applicable for use with gviz.
the most common applications of these tracks have been wrapped in a function, called glocationplot.
the glocationplot function displays several barplots in the same graph and marks their location in a region .fig.
<dig> short title: ai consistency for different alignment methods for fn <dig>  detailed legend: a comparison of fractions over snps between a star, b star with n-replaced snp reference genome, and c tophat <dig>  in the normal star and tophat <dig> run, the fraction lies around 1: <dig> for most snps, except snp  <dig> , which shows strong ai.
in c, however, the fractions are approximately 1: <dig> for all snps.
d this graph summarizes the total counts for each snp over all samples for the alignment methods.
see additional file  <dig> for the total allele count for each snp
mapping bias
an rna sequencing read that contains snps can lead to a mapping bias—eg, reads that are more similar to the reference will map more often.
this bias must be measured in the alignment step, such as through the generation of artificial reads that are equally distributed for both alleles over each snp of interest  <cit> .
in the alignment of reads, it is also possible to allow for more mismatches to decrease the bias toward the reference allele, but this step could affect the accuracy of the mapping  <cit> .
alignment to personal phased genomes is another method to handle mapping bias, requiring dna sequencing of the same individuals  <cit>  or ultimately personal transcriptomes, necessitating longer rna sequencing reads  <cit> .
to this end, allelicimbalance has a function that defines the expected allele ratios other than 1: <dig> to adjust for this mapping bias when searching for ai.
the package also has a function that creates a reference genome in which known snps are masked by the generic nucleotide n  <cit> , which can then be used in a realignment.
in this article, we reduced the mapping bias effect using this method and masked all known variants in dbsnp build  <dig>  <cit>  prior to alignment.
RESULTS
allelicimbalance can detect ai from rna sequencing data that originate from transcriptional material.
with sufficient read depth over a gene, it is even possible to detect and quantify the alleles in introns of the precursor mrna.
for example, we analyzed unpublished, strand-specific rna sequencing data from the livers of  <dig> individuals and the aortas of  <dig> subjects .
to exemplify how ai can be used in a simple qtl analysis, four genes with high coverage—fgb, c <dig>  kng, and itih4—were plotted as dual barplots .
the plots show the binomial test p-values and provide visual confirmation of the presence of ai events.
in this example, allelicimbalance demonstrates that there are cis effects for several individuals in all of these genes.
using established methods, such as eqtl, it would not have been possible to detect this effect in a limited sample size.
in all of the exemplified genes, most reads came from one strand, suggesting that the interference of lncrnas, for example, is low.
but, at least 40 % of human genes are transcribed in both directions  <cit> , potentially affecting the measurements of ai for a gene if there is ai on its antisense transcript.
to compare loci or individuals in which the read depth differs, it can be convenient to plot alleles as a fraction and inspect a wider region of all heterozygous snps, for example, of the same gene.
without interference from allele-specific splicing, we expect all snps over a gene to show the same pattern of fractions.
figure  <dig> shows an example for which there is consistency between heterozygous snps in a gene; there is no ai, but the overall 1: <dig> expression supports that the ai measurements are consistent in the rna-seq data.
to illustrate the reduction in mapping bias, we replaced the snps in the reference genome with the generic nucleotide indicator n. all snps in dbsnp build  <dig> were masked in this manner, and we then reperformed the alignment with star.
figure  <dig> shows an example of how such steps can improve the detection of true ai compared with a default run using star   <cit>  or tophat <dig>   <cit> .
CONCLUSIONS
the allelicimbalance package will be valuable in examining the genetics of rna sequencing experiments.
this software is a novel tool in the bioconductor environment, in which no infrastructure that can perform ai analyses exists.
the import functions are essential when retrieving allele counts for specific nucleotide positions from all rna-seq reads.
similarly, the statistical analysis and plotting functions are necessary to identify any allele-specific expression patterns in one’s data.
with merely a limited amount of samples, strong genetic effects on gene expression can be discovered.
availability and requirements
gpl3-licensed and available in the bioconductor framework.project name: allelicimbalance software
project home page: http://www.bioconductor.org/packages/release/bioc/html/allelicimbalance.html
operating system: linux, mac osx, windows
programming language: r
other requirements: none
license: gpl3
any restrictions to use by nonacademics: gpl3
additional files
additional file 1: figure a1-a <dig>   the corresponding barplots to figure  <dig> for a star alignment.
barplots for a tophat <dig> alignment.
comparison between star, star dbsnp-masked reference and tophat <dig> for ai fraction consistency in the apob gene.
a glocationplot for the fn <dig> gene with transcript annotation.
additional file 2:
includes counts, fractions and binomial test p-values for all individuals, rsids and alignment methods.
additional file 3:
includes total counts over all samples for each snp for the alignment methods for apob.
additional file 4:
includes total counts over all samples for each snp for the alignment methods for fn <dig>
competing interests
the authors declare that they have no competing interests.
authors’ contributions
jg and lf wrote the code, and all authors contributed to the design, draft of the manuscript, and critical revision of important intellectual content.
acknowledgments
this work was supported by the swedish research council  and the swedish heart-lung foundation.

 regulatory variants that alter gene expression can be examined, based on allelic imbalance, i.e., alleles can be differently expressed in an individual if the regulatory region around a gene differs. in rna sequencing data, it is possible to determine the allele from which a specific read originates when there is at least one heterozygous snp in the sequence read. an ai event indicates that there is a variant that changes gene expression within or near that gene. it only takes one individual, assuming that there is a heterozygous site in the gene of interest. the detection of an ai event is not trivial, comprising several steps, including library preparation, sequencing, mapping, and analysis of somatic mutations and rna-editing, which can bias the allele count. to counter such biases when determining the true ai for an exon or gene, a smaller region must be visualized to discover inconsistent patterns. the allelicimbalance package was developed to address these issues, allowing the user to test ai at a single gene or snp quickly. nevertheless, the package is suitable for performing any custom global ai analysis, because there is always a counting step and the need to store counts in a smart container, which facilitates access to custom requests from the user. for genes that have more than one heterozygous snp and at least one sample, there is a function to visualize ai consistency easily over the gene as an internal validation to select snps that are suitable for further ai qtl study. the package is easy to use, comprising an infrastructure that is linked to the bioconductor environment, and allows the user to pose genetic questions quickly.fig. short title: ai consistency using glocationplot. detailed legend: on top are the fractions of alleles over apob for snps with a maf > . each bar represents one of eight samples, and the grey lines in the middle show the snp locations in apob beneath in yellow. all snps shown are close around the black line, denoting 1: expression of the alleles. see additional file for the total allele count for each snp allelicimbalance was developed to provide usability for inexperienced as experienced r-users. for inexperienced users, there is a standard protocol to create an aseset from bam files, and functions, such as barplot, can be used directly on that aseset class object; experienced users can customize nearly any part of the workflow. the design is based on rna-sequencing, but allelicimbalance can be used with any allele that is focused on a count-based technique, such as digital qpcr. implementation management aseset is a new object class that summarizes sequencing data. it contains allele counts, phenotypes, and snp positions and inherits the summarizedexperiments class and all functions that can be applied to that class, such as subset and range operation. the class has support for strand- and nonstrand-specific data. the first step in ai analysis is to create an aseset from mapped data in bam file format and a set of snps of interest. the support functions will summarize the allele counts for each snp rapidly and save them in an aseset object.fig. short title: flowchart of a typical workflow in the allelicimbalance package fig. short title: a few simple commands are needed to construct an aseset-class object. detailed legend: if the bam files are unprocessed before being imported into r, we recommend elaborating the filtering on the mapping with regard to quality and perfect mate-pairs before counting the alleles detection equal amounts of reads are expected from two alleles, but one allele might be read more than the other by chance. a greater number of reads improves the estimate of the total distribution. statistical tests, such as the chi-square and binomial tests, generate the probability that an observed difference is due to this sampling bias. these relatively simple and general tests can be applied directly to aseset objects and return a matrix with p-values for each snp and sample. the user can easily apply other custom tests by taking advantage of the aseset accessor methods to retrieve allele fractions or counts, for example. visualization and annotation allelicimbalance has good visualization capabilities and provides a rich description of allele-specific expression in a region. the barplot function has options to display the data as a fraction or count plot and can be used with the bioconductor annotationdbi and genomicfeatures packages to show the annotation of a gene, an exon, and transcript information.fig. short title: the dual-strand barplot. detailed legend: the barplot from the allelicimbalance package shows the number of reads aligning to each allele and strand for one snp. upward bars indicate the strand, and downward bars indicate the strand. the numbers under the bars are the p-values from testing whether a difference in allele expression is due to chance. because the data are strand-specific, nearly all reads over this snp are mapped to one strand, consistent with the location of the investigated genes. all samples in this figure are from liver. a of the heterozygote individuals 5– and show no ai, whereas individual shows significant ai. but, the plot also shows expression off of the opposite strand, which might comprise antisense transcripts. b individuals and show ai. c individuals and show strong ai. d individuals and show ai, whereas subjects and show no ai. see additional file and for barplots using different aligners the bioconductor package gviz uses tracks and trellis graphics to imitate genome browsers’ visualization of a genomic region. to integrate allelicimbalance data as a track, it takes merely a function call over an aseset object to create an object that is directly applicable for use with gviz. the most common applications of these tracks have been wrapped in a function, called glocationplot. the glocationplot function displays several barplots in the same graph and marks their location in a region.fig. short title: ai consistency for different alignment methods for fn detailed legend: a comparison of fractions over snps between a star, b star with n-replaced snp reference genome, and c tophat in the normal star and tophat run, the fraction lies around 1: for most snps, except snp, which shows strong ai. in c, however, the fractions are approximately 1: for all snps. d this graph summarizes the total counts for each snp over all samples for the alignment methods. see additional file for the total allele count for each snp mapping bias an rna sequencing read that contains snps can lead to a mapping bias—eg, reads that are more similar to the reference will map more often. this bias must be measured in the alignment step, such as through the generation of artificial reads that are equally distributed for both alleles over each snp of interest. in the alignment of reads, it is also possible to allow for more mismatches to decrease the bias toward the reference allele, but this step could affect the accuracy of the mapping. alignment to personal phased genomes is another method to handle mapping bias, requiring dna sequencing of the same individuals or ultimately personal transcriptomes, necessitating longer rna sequencing reads. to this end, allelicimbalance has a function that defines the expected allele ratios other than 1: to adjust for this mapping bias when searching for ai. the package also has a function that creates a reference genome in which known snps are masked by the generic nucleotide n, which can then be used in a realignment. in this article, we reduced the mapping bias effect using this method and masked all known variants in dbsnp build prior to alignment.  allelicimbalance can detect ai from rna sequencing data that originate from transcriptional material. with sufficient read depth over a gene, it is even possible to detect and quantify the alleles in introns of the precursor mrna. for example, we analyzed unpublished, strand-specific rna sequencing data from the livers of individuals and the aortas of subjects. to exemplify how ai can be used in a simple qtl analysis, four genes with high coverage—fgb, c kng, and itih4—were plotted as dual barplots. the plots show the binomial test p-values and provide visual confirmation of the presence of ai events. in this example, allelicimbalance demonstrates that there are cis effects for several individuals in all of these genes. using established methods, such as eqtl, it would not have been possible to detect this effect in a limited sample size. in all of the exemplified genes, most reads came from one strand, suggesting that the interference of lncrnas, for example, is low. but, at least 40 % of human genes are transcribed in both directions, potentially affecting the measurements of ai for a gene if there is ai on its antisense transcript. to compare loci or individuals in which the read depth differs, it can be convenient to plot alleles as a fraction and inspect a wider region of all heterozygous snps, for example, of the same gene. without interference from allele-specific splicing, we expect all snps over a gene to show the same pattern of fractions. figure  shows an example for which there is consistency between heterozygous snps in a gene; there is no ai, but the overall 1: expression supports that the ai measurements are consistent in the rna-seq data. to illustrate the reduction in mapping bias, we replaced the snps in the reference genome with the generic nucleotide indicator n. all snps in dbsnp build were masked in this manner, and we then reperformed the alignment with star. figure  shows an example of how such steps can improve the detection of true ai compared with a default run using star or tophat.  the allelicimbalance package will be valuable in examining the genetics of rna sequencing experiments. this software is a novel tool in the bioconductor environment, in which no infrastructure that can perform ai analyses exists. the import functions are essential when retrieving allele counts for specific nucleotide positions from all rna-seq reads. similarly, the statistical analysis and plotting functions are necessary to identify any allele-specific expression patterns in one’s data. with merely a limited amount of samples, strong genetic effects on gene expression can be discovered. availability and requirements gpl3-licensed and available in the bioconductor framework.project name: allelicimbalance software project home page: http://www.bioconductor.org/packages/release/bioc/html/allelicimbalance.html operating system: linux, mac osx, windows programming language: r other requirements: none license: gpl3 any restrictions to use by nonacademics: gpl3 additional files additional file 1: figure a1-a the corresponding barplots to figure for a star alignment. barplots for a tophat alignment. comparison between star, star dbsnp-masked reference and tophat for ai fraction consistency in the apob gene. a glocationplot for the fn gene with transcript annotation. additional file 2: includes counts, fractions and binomial test p-values for all individuals, rsids and alignment methods. additional file 3: includes total counts over all samples for each snp for the alignment methods for apob. additional file 4: includes total counts over all samples for each snp for the alignment methods for fn competing interests the authors declare that they have no competing interests. authors’ contributions jg and lf wrote the code, and all authors contributed to the design, draft of the manuscript, and critical revision of important intellectual content. acknowledgments this work was supported by the swedish research council and the swedish heart-lung foundation.
one aspect in which rna sequencing is more valuable than microarray-based methods is the ability to examine the allelic imbalance of the expression of a gene. allelic imbalance analysis is subject to technical biases, due to differences in the sequences of the measured alleles. we present allelicimblance, a software program that is designed to detect, manage, and visualize allelic imbalances comprehensively. the visualization features can reveal notable, non-trivial allelic imbalance behavior over specific regions, such as exons. the software provides a complete framework to perform allelic imbalance analyses of aligned rna sequencing data, from detection to visualization, within the robust and versatile management class, aseset. allelic imbalanceallele-specific expressionrna sequencinggene expressionsnpissue-copyright-statement© the author 2015
 one aspect in which rna sequencing is more valuable than microarray-based methods is the ability to examine the allelic imbalance of the expression of a gene. this process is often a complex task that entails quality control, alignment, and the counting of reads over heterozygous single-nucleotide polymorphisms. allelic imbalance analysis is subject to technical biases, due to differences in the sequences of the measured alleles. flexible bioinformatics tools are needed to ease the workflow while retaining as much rna sequencing information as possible throughout the analysis to detect and address the possible biases.  we present allelicimblance, a software program that is designed to detect, manage, and visualize allelic imbalances comprehensively. the purpose of this software is to allow users to pose genetic questions in any rna sequencing experiment quickly, enhancing the general utility of rna sequencing. the visualization features can reveal notable, non-trivial allelic imbalance behavior over specific regions, such as exons.  the software provides a complete framework to perform allelic imbalance analyses of aligned rna sequencing data, from detection to visualization, within the robust and versatile management class, aseset. electronic supplementary material the online version of this article contains supplementary material, which is available to authorized users. keywords allelic imbalanceallele-specific expressionrna sequencinggene expressionsnpissue-copyright-statement© the author 2015 