Professional Documents
Culture Documents
Btac 492
Btac 492
https://doi.org/10.1093/bioinformatics/btac492
Advance Access Publication Date: 8 July 2022
Original Paper
Sequence analysis
Needle: a fast and space-efficient prefilter for estimating
the quantification of very large collections of expression
Received on January 12, 2022; revised on May 23, 2022; editorial decision on June 20, 2022; accepted on July 7, 2022
Abstract
Motivation: The ever-growing size of sequencing data is a major bottleneck in bioinformatics as the advances of
hardware development cannot keep up with the data growth. Therefore, an enormous amount of data is collected
but rarely ever reused, because it is nearly impossible to find meaningful experiments in the stream of raw data.
Results: As a solution, we propose Needle, a fast and space-efficient index which can be built for thousands of
experiments in <2 h and can estimate the quantification of a transcript in these experiments in seconds, thereby out-
performing its competitors. The basic idea of the Needle index is to create multiple interleaved Bloom filters that
each store a set of representative k-mers depending on their multiplicity in the raw data. This is then used to quantify
the query.
Availability and implementation: https://github.com/seqan/needle.
Contact: mitra.darvish@fu-berlin.de
Supplementary information: Supplementary data are available at Bioinformatics online.
Fig. 3. Example how the expression value is derived. The blue line stands for a tran-
ae ¼ Cxe ðT 0 Þ lead to a higher false positive rate and makes a correction necessary.
Xq
The number of observed minimizers at one level (no) is the result of
be ¼ Ci ðT 0 Þ
(2) true positives (ntp) and false positives, and it can be assumed that
i¼ye
m m
ae þ be ^ be < : no ¼ ntp þ ðn ntp Þ fpr (4)
2 2
That is, the index of the level at which the sum of all counts in this holds for n being the number of minimizers in a transcript and fpr
level (ae) and all levels above (be) is equal to or greater than half of the false positive rate of the underlying IBF for one specific experi-
the number of (w, k)-minimizers present in T (m2 ) and, in addition, ment. By transforming this formula, the number of true positives
the count of all levels above (be) is less than this number. From this, can be estimated by:
the median le can be approximated by
no n fpr
ntp ¼ (5)
m be 1 fpr
le ¼ ye ðye xe Þ : (3)
ae
In summary, each of the q IBFs created is searched once to find the
To calculate be, the number of found minimizers at levels higher two levels x and y. As a result of this, the search time is O(q).
than ye has to be considered, otherwise the threshold of m2 might Although this seems like a drawback, in reality, a small number of
never be met. This is problematic as every IBF has its own false posi- levels q 15 is sufficient and our current search speed outperforms
tive rate. Therefore, summing up the results of multiple IBFs would REINDEER by a factor of 27 1205 (see Table 2).
4104 M.Darvish et al.
The described search could either start with IBF1 and then search and the expression values as determined by the respective tool.
IBFs with increasing levels, or start with the IBFq and then search Second, the Spearman correlation with the microarray expression
downwards. IBF1 depends on either the first user-defined threshold values was determined. And third, the mean square error of the
or the cutoff value, which are usually not set to 0 to exclude mini- expected fold change of the ratio between C and D and fold change
mizers resulting from erroneous reads. Therefore, Needle starts with calculated from the expression values determined by the different
IBFq because then it is not necessary to account for this dependency. tools was reported. The fold change based on the expression values
is based on the ratio of C and D and was calculated by the following
formula:
2.4.3 Normalization
Normalization is an important step in any further downstream ana- D Ai þ 3Bi
lysis, but not every normalization method is affordable for a large ¼ (6)
C 3Ai þ Bi
dataset. For instance, a normalization method considering all avail-
able data for the normalization [like DESeq2 (Love et al., 2014)] Where Ai and Bi represent the expression values of a transcript i for
2.50 GHz with 20 cores and 58MB L3 cache). The false positive rate smaller variance in most cases. Furthermore, Needle’s performance
of Needle was set to 0.05 for all analyses, as this is a typically used with different window sizes is in all instances accurate enough and
false positive rate with Bloom filters (Bingmann et al., 2019). In our no big difference between the window sizes can be spotted.
supplementary, we provided the same results with a rather high false Moreover, the variation of all tools increases with the fold change
positive rate of 0.3 as suggested by Bingmann et al. (2019) in their for both the differentially expressed genes and the coverages, indi-
approach. cating that the correct quantification of highly expressed transcripts
is more difficult to determine, probably due to repetitive regions.
For the SEQC dataset, we expected kallisto and Salmon to per-
3.1 Accuracy
form better than REINDEER and Needle as they use more informa-
For the simulated dataset, Needle was applied with user-defined
tion such as the order of the k-mers, but surprisingly REINDEER
thresholds by using 15 thresholds ranging from 5 to 520. This covers
and Needle perform as good as kallisto and Salmon (see Table 1)
all coverages multiplied with the possible fold changes to see
regarding the Spearman correlation. In some cases, Needle performs
Table 2. Comparison of Needle and REINDEER for k ¼ 21 on the large real dataset
Build Query
Note: For the query comparison, the run times for 1/100/1000 sequence(s) were measured. The RAM usage was the same for all query comparisons. The
REINDEER build with one thread resulted in a zlib error, the REINDEER log query resulted in a malloc error and the REINDEER query with 4 threads in a seg-
fault, in these cases the time for loading the index is reported. Needle ðw; kÞ represents Needle based on ðw; kÞ-minimizers. Build-Time is in minutes, Query-Times
in seconds, RAM, and Index size in GB. The values in parentheses are the results when using compressed IBFs.
4106 M.Darvish et al.
queries was nonetheless possible, as at least loading the index the search, this took around 9 min. Hence, Needle also outperforms
worked. These loading times are reported for REINDEER’s query, if in every version the REINDEER log index.
the query resulted in an error. The number of threads only improves the query performance.
Unlike the accuracy analysis on the SEQC dataset, we used 15 Therefore, the performance gain is more visible the more sequences
levels to avoid giving Needle an advantage by storing too few levels. are searched.
But even for the biggest Needle index, all IBFs from level 10 onward Querying Needle with window sizes of 25 and 41 takes around
only had a size of a few MBs. Thus, storing even more levels would or less than a minute (for w ¼ 25) and less than half of a minute (for
have little impact on Needle’s overall performance, which makes w ¼ 41) for all numbers of transcripts. As expected, we can see that
this a fair comparison to REINDEER. the faster loading of a smaller compressed Needle index has less im-
Needle outperforms REINDEER in every aspect, it is up to 48 pact with an increasing number of transcripts or the usage of mul-
times faster in construction than REINDEER log when using a win- tiple threads, making the uncompressed searches the fastest option
dow size of 41 and in its compressed form 16.4 times smaller (see for searching 1000 transcripts as the overhead of the compressed
Table 2). Comparing Needle with a window size of 21 to the exact version becomes the determining factor.
REINDEER index using 4 threads, Needle is two times faster and its
index in compressed form takes less than half of REINDEER’s size. 3.3 Identifying tissue-specific genes
Even compared to REINDEER’s smaller index (REINDEER log), In this experiment, we want to examine if the overexpressed genes
Needle performs better in every version regarding construction time identified with Needle were correctly annotated to the tissue type of
and compressed index size. origin. Quantifying and normalizing all protein-coding human tran-
Needle (21, 21) has a larger memory footprint than REINDEER scripts (103, 155 total) took <20 min with one thread (<6 min with
because all IBFs are loaded into memory during construction. four threads).
However, we believe Needle is applicable for most modern use cases The differential expression analysis led to the discovery of 1423
as a memory usage of 121 GB can be handled by most modern serv- differentially expressed genes for the blood tissue, 2293 for the brain
ers and once the Needle index is created, the memory usage is only a tissue and 90 for the breast tissue. As can be seen in Figure 6, the
fraction of the built memory usage (see Table 2). found genes indeed correspond to known genes related to the tissue
While Needle (21, 21) in its uncompressed form has a larger of origin. The genes overexpressed in brain tissue samples are associ-
index size than REINDEER, Needle has the ability to rely on a ated with the temporal, occipital, parietal and frontal lobe. The
much smaller index through compression, the usage of a greater overexpressed genes from the blood samples are associated with
window size or the usage of a larger false positive rate (see blood directly but also to tissues involved in leukemia, indicating
Supplementary Table S5). that the blood tissue samples in the experiments might originate
The advantage of a greater window size can be seen in the huge from cancer patients. The overexpressed genes from the breast tissue
show a high enrichment for columnar cells, which is reasonable as
impact it has on the efficiency (see Table 2). An increase of the win-
columnar cell lesions are diagnosed often in breast tissue due to the
dow size by 4 [(25, 21)-minimizers here, (23, 19)-minimizers in the ac-
increase in mammography screening (Logullo and Nimir, 2019).
curacy datasets], which was shown to be almost as accurate as a
Moreover, already known associations are found. For example,
window size equaling the k-mer size, leads to an improvement in the
the association between brain and kidney tissue (Chen et al., 2021)
construction time, the RAM usage and the index size by a factor of 3. or the association between breast and eye tissue (Houlston and
For an increase in the window size by 20 [(41, 21)-minimizers here, Damato, 1999).
(39, 19)-minimizers in the accuracy datasets] this speedup factor is at Furthermore, we performed a disease ontology analysis as well
least 12. and as can be seen in the Supplementary Table S7, the associated
Therefore, it is reasonable to use greater window sizes because genes also correspond to the tissue of origin. This proves that the dif-
the small loss of accuracy is exchanged for a huge gain in efficiency. ferentially expressed genes found by Needle are useful for an ex-
The advantages of Needle can also be seen in its fast query time ploratory analysis.
(see Table 2). When querying 1000 transcripts, Needle with The point of the performed analysis was not to find new revela-
ðw; kÞ ¼ ð41; 21Þ needs 15 s, which is over 100 times faster than tions about the blood, brain or breast tissue, but demonstrate a use
REINDEER’s 1, 710 s and still vastly faster than even querying just case of Needle. Unlike kallisto or Salmon, Needle is capable of quanti-
one transcript with REINDEER, which takes more than 800 s. Even fying thousands of genes in thousands of experiments in minutes.
with all k-mers ðw; kÞ ¼ ð21; 21Þ, Needle is over 10 times faster. Therefore, if a researcher is interested in finding new associations be-
While we could not run a query with REINDEER log successfully, tween different tissues, different diseases or different genomes, Needle
we were capable of loading the index, which is a necessary step in can be used as a starting point to find interesting transcripts.
Needle 4107
Fig. 6. Gene ontology analysis for genes found differentially expressed in blood, brain and breast tissue of 1742 RNA-seq experiments sorted by their fold enrichment. The col-
Table 3. Confusion matrix difference between using the median or the interquartile mean, but
further research would be necessary to confirm this hypothesis.
CCND1 ERRB2 FOXM1 MYC
Moreover, we recommend the usage of minimizers instead of k-
True positives 339 267 168 232 mers [as we have done already in Seiler et al. (2021)]. While there is an
False positives 102 58 118 213
accuracy loss by using minimizers, the massive space and speed gain
makes this a reasonable approach. Which leads to the question whether
True negatives 1088 1132 1072 977
using k-mers in the contexts of prefilters is still a sensible choice.
False negatives 213 285 384 320
We would have liked to also compare Needle to its other com-
False positive rate 0.09 0.05 0.1 0.18
petitor Gazelle, but to our knowledge, the software is not publicly
False negative rate 0.39 0.52 0.7 0.58
available yet. Based on the analysis done by the authors themselves,
the Gazelle index size of the 2586 RNA seq files that we used here
Note: The results of finding breast cancer samples by searching for overex-
as the basis for our large dataset is 36.65 GB and is constructed in
pression of the breast cancer oncogens CCND1, ERRB2, FOXM1 and MYC
9.23 h. It is not apparent to us whether they used the already estab-
in absolute numbers.
lished cutoffs as well, but assuming they did and assuming that tak-
ing b1742
2568c ¼ 0:6 of their reported size is a lower bound for storing
At the same time, this analysis can be seen as a confirmation of 1742 of the 2586 RNA seq files we used, then we would expect a
already established knowledge. Therefore, Needle can also be used Gazelle index of size 21.99 GB to be constructed in 5.5 hours. This
as a sanity check. is longer than the compressed Needle index for k-mers and all
Needle indices with a bigger window than k-mer size. Moreover, the
construction of Gazelle takes almost twice as long as even the slow-
3.4 Identifying cancer samples within a collection
est Needle construction.
As shown in Table 3, the false positive rate is low for all oncogenes,
Using 0.6 of Gazelle’s size seems a rather generous lower bound: if
but depending on the oncogene the false negative rate is quite high.
we compare the REINDEER index sizes reported in this paper to the
Nevertheless, the analysis was merely a proof of concept to show
ones reported in the REINDEER paper (Marchet et al., 2020) for the
that the quantification can be used for identifying a subset of experi- 2586 RNA seq files, then the index size we determined for the 1742
ments of interest. The good results of the oncogene CCND1 are files make up more than 0.85 of the size for the 2586 files. This is not
promising that this is possible. A more in-depth analysis is necessary surprising, as we reduced the dataset by not considering RNA seq files
to determine how oncogenes can more effectively be used to identify with a smaller read size and therefore a smaller k-mer content.
breast cancer samples reliably, as it seems apparent that the usage of Moreover, another advantage of Needle is that the false posi-
only one oncogene has limitations. tive rate can be set be the user, such that its speed and space con-
sumption can be directly influenced by the level of desired
accuracy. Unfortunately, determining the influence of the false
4 Discussion positive rate on the actual accuracy is not straightforward be-
A database is only as good as its utility allows it to be, therefore stor- cause the false positive rate influences the estimation in two ways:
ing an enormous amount of biological data without the possibility finding the levels where the estimation should happen (xe, ye in
to search through it efficiently makes storing the data almost point- Equation (2)) and determining the number of found minimizers
per level (ae, be in Equation (2)).
less. Hence, finding a solution to this bottleneck is one of the most
Even a high false positive rate of 0.3 can be reasonable—see
important challenges in computational biology today.
Supplementary Figures S7 and S8 and Table S4, where we found a
In our study, we have shown that it is not necessary to store the
similar performance on the simulated dataset and a weaker correlation
exact occurrences of all representative k-mers, it is enough to map
for every Needle version on the SEQC data. Here, we can see for the
them to some levels. Thus, all recent research (Bingmann et al.,
first time an actual difference in the window sizes, as the accuracy
2019; Harris and Medvedev, 2020; Kitaya and Shibuya, 2021;
strongly decreases with an increasing window size. This shows that the
Lemane et al., 2021; Marchet et al., 2020; Pandey et al., 2018; accuracy depends on the picked ðw; kÞ-minimizers and the false posi-
Seiler et al., 2021; Solomon and Kingsford, 2016, 2018; Sun et al., tive rate. ðw; kÞ-minimizers with a greater window size have fewer min-
2018; Yu et al., 2018) for finding a fast and space efficient data imizers for a sequence than ðw; kÞ-minimizers with a smaller window
structure to answer in which experiments a transcript is present, can size, therefore one false positive minimizer has a bigger impact for
be easily adapted to a tool estimating expression values by storing greater window sizes. Further research is necessary to find a formula to
this data structure multiple times. However, as we demonstrated in estimate the impact of those two factors on the accuracy.
our previous study (Seiler et al., 2021), the most efficient data struc- However, even with a greater window size and a high false posi-
ture at the moment is the IBF. tive rate, the accuracy results are still good enough for a prefilter
Furthermore, we confirmed the finding of Zhang et al. (2021) and might be a reasonable choice considering the advantages of a
that using a simple measure like the median or the interquartile higher false positive rate, which is a further decrease in construction
mean [as done by Zhang et al. (2021)] of the k-mer occurrences and query time, RAM usage and index size. For example, the
results in meaningful expression values. Due to the similarity in ro- Needle index (41, 21) with false positive rate 0.3 would need <1 GB
bustness to outliers, we would not expect to see a significant of space.
4108 M.Darvish et al.
Furthermore, Needle could be further improved by using differ- Bloom,B.H. (1970) Space/time trade-offs in hash coding with allowable errors.
ent false positive rates per level. As the search starts at the highest Commun. ACM, 13, 422–426.
level and numerous transcripts will be found along the way, increas- Bray,N.L. et al. (2016) Near-optimal probabilistic RNA-seq quantification.
ing the false positive rate of the lower levels should have only a small Nat. Biotechnol., 34, 525–527.
Chen,X. et al. (2021) Kidney damage causally affects the brain cortical struc-
impact on the accuracy while having a greater influence on the size,
ture: a mendelian randomization study. eBioMedicine, 72, 103592.
as the lower level IBF s are the biggest ones. Before such an improve-
Dadi,T.H. et al. (2018) DREAM-Yara: an exact read mapper for very large
ment is implemented, though, a more profound understanding of
databases with short update time. Bioinformatics, 34, i766–i772.
the effect of the false positive rate on the accuracy is needed. Dobin,A. et al. (2013) STAR: ultrafast universal RNA-seq aligner.
Moreover, the memory footprint of Needle could be further Bioinformatics, 29, 15–21.
improved by loading only a few IBFs to memory at a time, this ap- Frazee,A.C. et al. (2015) Polyester: simulating RNA-seq datasets with differ-
proach will most probably increases the built time. A more in-depth ential transcript expression. Bioinformatics, 31, 2778–2784.
analysis is necessary to determine the best approach in terms of Ge,S.X. et al. (2019) ShinyGO: a graphical gene-set enrichment tool for ani-