Import Data)
Geographic & Journal Analysis)
Preprocess)LDA Inference)Stability & Sensitivity)
Final LDA Model)
Topic Trends)
LDAShiny is a web application built with Shiny (Chang et
al., 2017) and the golem framework (Fay et al., 2022). It lets you run
an exploratory review of the scientific literature with the Latent
Dirichlet Allocation model (LDA; Blei, Ng and Jordan, 2003) without
writing code: from loading bibliographic data to interpreting topics and
tracking how they evolve over time.
This guide walks through every tab of the application in the recommended order:
| Step | App tab | What it does |
|---|---|---|
| 0 | About |
Description, technical specifications and how to cite the package. |
| 1 | Import Data |
Imports and merges Scopus, Web of Science or bibliometrix files; cleans them with PRISMA criteria; summarizes the corpus. |
| 1b | Geographic & Journal Analysis |
Production tables and chart by country and journal; world choropleth map; international collaboration network. |
| 2 | Preprocess |
Cleans the text, builds the document-term matrix (DTM) and lets you refine stopwords. |
| 3 | LDA Inference |
Fits LDA models over a range of K and selects the K with the highest coherence. |
| 4 | Stability & Sensitivity |
Assesses how robust the choice of K is. |
| 5 | Final LDA Model |
Trains the final model and provides tables, word clouds, the theta matrix and LDAvis. |
| 6 | Topic Trends |
Classifies topics as increasing, declining or stable across years. |
The package requires R >= 4.1.0. Once installed, the application starts with a single function:
Bibliographic files (for example, Scopus exports) can be large. Shiny limits file uploads to 5 MB by default; if your files are larger, raise the limit before launching the application:
Each step depends on the output of the previous one, so it is best to follow the order of the sidebar:
| Module | Receives | Provides |
|---|---|---|
Import Data |
Scopus / WoS / bibliometrix / Excel files | Cleaned table of documents (with a country
column). |
Geographic & Journal Analysis |
Cleaned table of documents | Production tables, choropleth map and collaboration network. |
Preprocess |
Table of documents | Final DTM (sparse matrix) and term-frequency table. |
LDA Inference |
DTM | Coherence table and optimal K. |
Stability & Sensitivity |
DTM, coherence table, optimal K | Stability per K and sensitivity to the weights. |
Final LDA Model |
DTM, optimal K, table of documents | Final model, beta/gamma/theta matrices, topic-by-year intensity. |
Topic Trends |
Topic-by-year intensity | Trend classification for each topic. |
The download buttons of each module stay disabled until the corresponding analysis has been run.
The About tab summarizes what the application does, its
technical specifications (version, framework and main packages), the
recommended way to cite LDAShiny, and information about the
research group and the author.
Import Data)First choose an action in the Select an action menu:
| Action | What it loads |
|---|---|
Merge Scopus + Web of Science |
One or more Scopus CSV files and one or more Web of Science TXT files, merged into a single table. Click Process and Merge. |
Load Integrated Excel File |
An already integrated .xlsx file (for
example, one previously downloaded from this same tab). It is processed
as soon as it is uploaded. |
Load Bibliometrix File |
An .xlsx or .RData file
exported from Biblioshiny or produced with
bibliometrix::convert2df(). It is mapped automatically to
the LDAShiny format. |
The fields used by the rest of the application are
title, abstract, year,
Journal, doi and database; the
PRISMA cleaning also uses affiliations. For Excel files,
column names are matched case-insensitively and the usual aliases are
accepted (for example TI, AB, PY,
SO, DI, DB, C1). The
Excel file should include a database column, because the
training module uses it to compute topic intensity by source.
Every upload goes through a sequence of filters, inspired by the PRISMA scheme (Page et al., 2021), applied in order, and the counts are recorded:
| PRISMA phase | Criterion |
|---|---|
| Identification | Records without a title. |
| Screening | Duplicate removal: by normalized DOI; records without a DOI are compared using a fingerprint made of the first 200 characters of the abstract, the year and the journal. |
| Screening | Records without an abstract (including placeholders such as “[No abstract available]”). |
| Eligibility | Records without an affiliation (only if the affiliations column exists). |
| Eligibility | Records without a year. |
| Eligibility | Records without a journal or source. |
After filtering, a country column is added (the first
country in the affiliations). This column does not remove records and is
not a PRISMA step. When the upload finishes, the application shows an
import summary, and the current status appears in the
Instructions and Status box.
Once the data are loaded, the other tabs of the module let you inspect them before moving on:
Journal Count plot supports a bar or lollipop style and
between 5 and 50 journals; the Year Count plot shows
production by year. The customization dropdown controls labels, theme,
font, colors, point size and export options (PNG, TIFF, JPEG or PDF,
with width, height and DPI).country column.Geographic & Journal Analysis)This module is available as soon as data have been imported. It provides three complementary views of the corpus and does not affect the modeling workflow.
The left panel controls the Settings for all three views in this tab:
| Control | Description |
|---|---|
| Top N countries | Number of leading countries shown in the country table (5–50, default 20). |
| Top N journals | Number of leading journals shown in the journal table (5–50, default 20). |
| Variable | Whether the chart shows countries or journals. |
| Style | Bar or lollipop chart. |
| Top N to plot | Number of entries shown in the chart (5–30, default 15). |
| Customize chart | Dropdown with labels, theme, font size, colors, alpha and export options (PNG, TIFF, JPEG or PDF, with width, height and DPI). |
The Results panel has three inner tabs:
A world choropleth map of documents by country. Options:
| Control | Description |
|---|---|
| Color Palette | viridis family (viridis, magma, plasma, inferno, cividis, mako, rocket, turbo) or ColorBrewer palettes (Blues, Reds, YlOrRd, YlGnBu, Spectral). |
| Color Scale | Logarithmic (log10) or linear. |
| Palette Direction | Normal or reversed. |
| Map Title | Editable title. |
| Color NA countries | Fill color for countries not present in the corpus. |
| Border color / Border width | Appearance of country borders. |
Export options let you download the map (PNG, TIFF, JPEG or PDF) and the underlying country frequency table (Excel).
This tab builds an international co-authorship network from the
affiliations column. For each record the application
extracts all countries mentioned in the affiliations, creates a pair
(country A, country B) for every co-authored combination, aggregates the
pairs across the corpus, and visualises the result as a graph.
Filters and visual controls:
| Control | Description |
|---|---|
| Min. collaborations | Minimum edge weight (number of co-authored records) for a link to appear. |
| Max. countries to show | The network keeps only the top N countries by degree, to avoid overplotting. |
| Network Layout | Seven options: Fruchterman-Reingold (default), Kamada-Kawai, Circle, Star, Grid, Sphere and Random. |
| Node size scale | Scales node area (proportional to weighted degree / strength). |
| Edge transparency | Alpha of the edges. |
| Node color / Edge color | Base colors when no metric is selected for the gradient. |
| Label size | Size of the country labels. |
| Color nodes by | Node color gradient based on a centrality metric (see table below). |
| Metric color palette | Palette for the node color gradient (viridis family or ColorBrewer). |
Click Build Network to compute the graph. The three inner tabs show:
Available centrality metrics:
| Metric | Description |
|---|---|
| Strength | Sum of edge weights (total co-publications). |
| Degree | Number of distinct partner countries. |
| Betweenness | Fraction of shortest paths passing through the node (normalized). Uses inverse weights so that stronger links are treated as shorter paths. |
| Closeness | Inverse of the average shortest-path length to all other nodes (normalized). |
| PageRank | Authority score based on the link structure, weighted by collaboration count. |
| Hub score | Kleinberg hub score: nodes that link to many important authorities. |
| Authority score | Kleinberg authority score: nodes linked to by many important hubs. |
| Clustering coefficient | Local transitivity: fraction of a node’s neighbors that are also connected to each other. |
Preprocess)This module turns text into a document-term matrix. Everything is configured in the Settings tab and run with Run Preprocessing.
| Option | Description |
|---|---|
| Select text column | Column with the text to model. Default:
abstract. |
| Select document ID column | Column that identifies each document. Default:
title (or doi if there is no title). |
| Upload Additional Stopwords | .xlsx file with extra stopwords in the
first column, one per row and no header. |
| Min n-gram / Max n-gram | n-gram size, from 1 to 3. Default 1 and 2 (single words and bigrams). |
| Apply stemming | Applies the Porter algorithm. On by default. |
| Remove numbers / Remove punctuation | Remove numbers and punctuation. On by default. |
| Sparse filter | Maximum sparsity allowed per term (0.90 to 0.9999; default 0.995). The lower the value, the more rare terms are removed. |
| Number of CPUs | Cores used to build the DTM. |
The text is always converted to lowercase and English stopwords are always removed, together with those from the uploaded file and any added interactively. For this reason the application is designed for corpora in English.
The other tabs of the module show and let you refine the result:
tf_mat.xlsx) and the final DTM
(dtm_final_sparse.rds).LDA Inference)The module fits an LDA model for each value of K in the chosen range, in parallel, and computes the coherence of every topic (Mimno et al., 2011). The summary measure for each model is the mean coherence of its topics.
| Option | Default |
|---|---|
| Minimum number of topics (k start) | 5 |
| Maximum number of topics (k end) | 40 |
| Step for k | 1 |
| Iterations | 500 |
| Burn-in | 50 |
| Alpha | 0.1 |
| Number of CPUs | depends on the machine |
Click Run LDA Inference. When it finishes, the status reports the K with the highest mean coherence and the elapsed time. Results appear in two tabs:
coherence_mat.xlsx).The K with maximum coherence is a starting point, not a final decision. Coherence curves often have several regions with similar values, which is why the next step evaluates how robust the choice is.
Stability & Sensitivity)This module checks whether the chosen K is robust, using three ideas:
| Option | Default | Description |
|---|---|---|
| Number of seeds | 5 (3 to 20) | Independent runs per K. |
| Base seed | 42 | First seed in the sequence. |
| Iterations per seed | 300 | Iterations of each run. |
| Burnin per seed | 150 | Warm-up iterations. |
| CPUs for parallel training | depends on the machine | Available cores. |
| Select K candidates | optimal K and its neighbors | Values of K to evaluate; the ones tested in
LDA Inference are offered. You must select at least
two. |
All criteria are normalized to the range 0 to 1 across the evaluated K values:
| Criterion | Default weight | What it measures |
|---|---|---|
| Plateau | 0.30 | Favors K values where coherence changes little relative to the previous K, that is, flat regions of the curve. |
| Stability | 0.30 | Mean ARI of the runs against the first run. |
| Parsimony | 0.20 | Favors smaller K values. |
| Interpretability | 0.20 | Approximation based on coherence (70%) and on low variability of coherence across runs (30%). |
Weights are rescaled automatically so that they sum to 1. Interpretability is a numerical approximation: it does not replace reading the terms of each topic.
Click Run Stability Analysis. Results are organized in five tabs:
Plots are downloaded as PNG and tables as Excel. A K that wins under almost every scheme and has a high ARI is easier to defend than one that wins under a single set of weights.
Final LDA Model)The number of topics (Number of topics (K)) is
initialized with the optimal K from LDA Inference, but you
can change it. When the optimal K is received, alpha is also updated
automatically to 50 / K (rounded to two decimals).
| Option | Default |
|---|---|
| Iterations | 500 |
| Burn-in | 50 |
| Alpha (Dirichlet prior on theta) | 0.1 (updated to 50/K when synchronized with the inference step) |
| Beta (Dirichlet prior on phi) | 0.05 |
| CPUs for Model Training | all but one |
| Optimize Alpha during run | on |
| Model Evaluation Metrics | likelihood and coherence (R-squared is optional) |
Click Train Final LDA Model. When it finishes, Download Final LDA Model (.rds) is enabled.
| Tab | Content | Download file |
|---|---|---|
| Model Evaluation Metrics | Model parameters and the selected global metrics (mean log-likelihood, mean coherence, R-squared). | lda_model_metrics.xlsx |
| Top Terms Matrix | One column per topic (t_1,
t_2, …) and one row per rank (1 = most important term). The
number of terms (M) is configurable. |
lda_top_terms_matrix.xlsx |
| Document Topic Assignment | Dominant topic of each document (the one with the highest gamma). | toptopic.xlsx |
| Top Documents per Topic | The documents with the highest gamma in each topic; the number is configurable. | clasificacion.xlsx |
| Topic-Term Weights (Beta) | Topic-term matrix in long format. The view shows the top 5 terms per topic; the download contains the full matrix. | tidy_beta.xlsx |
| Document-Topic Weights (Gamma) | Document-topic matrix in long format. The view shows a sample; the download contains the full matrix. | tidy_gamma.xlsx |
| Topic Word Cloud | Word cloud of the chosen topic, with maximum number of words, base color or RColorBrewer palette, and export (PNG, JPEG, PDF or TIFF, with width, height and DPI). | depends on the format |
| Theta Matrix (Full) | Full document-topic matrix with the title,
country and Journal metadata and one column
per topic. |
theta_matrix_full_K<K>_<date>.xlsx |
| LDAvis | Interactive topic visualization (see below). |
Topics are named t_1, …, t_K. The Top Terms
Matrix, the Theta Matrix and LDAvis all use that same numbering: topic
t_3 in the terms table is topic 3 in LDAvis and column
t_3 of the Theta Matrix. To guarantee this, LDAvis is
generated without reordering the topics by prevalence, which is its
default behavior. Before opening it, the application checks that the top
term of every topic in LDAvis matches the one in the table and warns you
if it finds a difference.
Click Abrir LDAvis and the visualization opens in a new browser tab (allow pop-ups). LDAvis (Sievert and Shirley, 2014) projects the topics into two dimensions and shows the most relevant terms for the selected topic.
The file lda_final_model.rds contains the object
returned by textmineR::FitLdaModel(), to which the
application adds the prevalence of each topic (as a percentage), the
labels and the parameters used. You can load it in R to continue the
analysis:
Topic Trends)This module starts from the intensity of each topic by year, computed as the average gamma of the documents in that year, and evaluates its evolution with two complementary tests:
| Option | Default | Description |
|---|---|---|
| Significance Level (α) | 0.05 | Significance threshold. |
| Exclude last year | on | Excludes the last year of the corpus, which is often only partially indexed. |
| Apply FDR correction | on | Adjusts p-values for multiple comparisons with the Benjamini-Hochberg method (1995). |
| Select Topic for Plotting | first topic | Topic to plot; it appears after the analysis has been run. |
Click Run Trend Analysis. A topic needs at least four years of data to be evaluated; with fewer, it is classified as stable because of insufficient data.
The classification requires the two tests to converge:
| Result | Condition |
|---|---|
Increasing / Declining |
The OLS slope and τ have the same sign and both tests are significant. |
Increasing* / Declining* |
Both tests agree in sign, but only one is significant. |
Stable |
Neither is significant, the signs differ, or there is not enough data. |
topic_year_intensity_data.xlsx).topic_trend_regression_results.xlsx).| Module | File |
|---|---|
Import Data |
Integrated Excel file, country table, PRISMA table, PRISMA diagram and plots |
Geographic & Journal Analysis |
Country table, journal table, production chart, choropleth map, country frequency table, edge list and network metrics (all as Excel or image files) |
Preprocess |
tf_mat.xlsx,
dtm_final_sparse.rds,
custom_stopwords_<date>.xlsx |
LDA Inference |
coherence_mat.xlsx and coherence plot |
Stability & Sensitivity |
Stability_Results_<date>.xlsx,
Weight_Sensitivity_<date>.xlsx and PNG plots |
Final LDA Model |
lda_final_model.rds,
lda_model_metrics.xlsx,
lda_top_terms_matrix.xlsx, toptopic.xlsx,
clasificacion.xlsx, tidy_beta.xlsx,
tidy_gamma.xlsx,
theta_matrix_full_K<K>_<date>.xlsx, word
clouds |
Topic Trends |
topic_year_intensity_data.xlsx,
topic_trend_regression_results.xlsx and plot |
Model Evaluation Metrics tab), and store the
.rds file of the final model.Refine Stopwords to remove generic domain terms and run
the workflow again.Sparse filter).shiny.maxRequestSize before launching the application (see
“Installation and launch”).Topic Trends shows no results. Train
the final model first: this module uses the topic-by-year intensity
computed in Final LDA Model, which requires the imported
data to have year and database columns.LDA Inference and Stability & Sensitivity
train many models. Narrow the range of K, use a step larger than 1 for a
first exploration, and assign more CPUs.If you use LDAShiny in your research, please cite:
De la Hoz-M., J., Fernandez-Gomez, M. J. and Mendes, S. (2021). LDAShiny: An R Package for Exploratory Review of Scientific Literature Based on a Bayesian Probabilistic Model and Machine Learning Tools. Mathematics, 9(14), 1671. https://doi.org/10.3390/math9141671
Benjamini, Y. and Hochberg, Y. (1995). Controlling the false discovery rate: a practical and powerful approach to multiple testing. Journal of the Royal Statistical Society: Series B, 57(1), 289-300.
Blei, D. M., Ng, A. Y. and Jordan, M. I. (2003). Latent Dirichlet Allocation. Journal of Machine Learning Research, 3, 993-1022.
Chang, W., Cheng, J., Allaire, J. J., Sievert, C., Schloerke, B., Xie, Y., et al. shiny: Web Application Framework for R. R package.
Fay, C., Rochette, S., Guyader, V. and Girard, C. (2022). Engineering Production-Grade Shiny Apps. Chapman & Hall/CRC.
Hubert, L. and Arabie, P. (1985). Comparing partitions. Journal of Classification, 2, 193-218.
Mann, H. B. (1945). Nonparametric tests against trend. Econometrica, 13(3), 245-259.
Mimno, D., Wallach, H., Talley, E., Leenders, M. and McCallum, A. (2011). Optimizing semantic coherence in topic models. Proceedings of EMNLP, 262-272.
Page, M. J. et al. (2021). The PRISMA 2020 statement: an updated guideline for reporting systematic reviews. BMJ, 372, n71.
Sievert, C. and Shirley, K. (2014). LDAvis: A method for visualizing and interpreting topics. Proceedings of the Workshop on Interactive Language Learning, Visualization, and Interfaces, 63-70.