-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathREADME.qmd
More file actions
307 lines (230 loc) · 8.21 KB
/
README.qmd
File metadata and controls
307 lines (230 loc) · 8.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
# NIH Grant Typst Templates
A modern, reproducible workflow for creating NIH grant applications using Typst, with integrated support for R and Python data analysis via Quarto.
[](https://github.com/brainworkup/nih-grant-typst/actions/workflows/compile-typst.yml)
[](https://opensource.org/licenses/MIT)
## 🚀 Quick Start
```bash
# Clone the repository
git clone https://github.com/brainworkup/nih-grant-typst.git
cd nih-grant-typst
# Set up the environment (choose one)
conda env create -f environment.yml # Recommended: includes everything
# OR
pip install -r requirements.txt # Python only
# OR
Rscript -e "install.packages(c('tidyverse', 'ggplot2', 'patchwork', 'viridis'))" # R only
# Compile example templates
./scripts/compile_templates.sh
```
## 📋 Features
- ✅ **NIH-compliant formatting** - Automated margins, fonts, and page limits
- ✅ **Multiple grant types** - R01, R03, with more coming soon
- ✅ **Integrated data analysis** - Seamless R and Python integration
- ✅ **Reproducible research** - Quarto-based progress reports
- ✅ **Smart reference management** - BibTeX with NIH-style formatting
- ✅ **Version control friendly** - Clean text-based format
- ✅ **Automated compilation** - GitHub Actions for PDF generation
- ✅ **Modular components** - Reusable sections across grants
## 🏗️ Repository Structure
```
nih-grant-typst/
├── templates/ # Typst templates for grant applications
│ ├── R01/ # R01 grant template
│ ├── R03/ # R03 grant template
│ └── shared/ # Shared components (aims, budget)
├── scripts/ # Helper scripts and analysis code
│ ├── analysis/ # Data analysis scripts
│ │ ├── figures/ # R/Python scripts for figures
│ │ └── tables/ # R scripts for tables
│ └── helpers/ # Utility scripts
├── quarto/ # Progress report templates
├── data/ # Data organization structure
│ ├── raw/ # Original, unmodified data
│ ├── cleaned/ # Processed, analysis-ready data
│ └── scripts/ # Data processing scripts
├── examples/ # Example outputs and figures
└── outputs/ # Compiled PDFs (generated)
```
## 📖 Complete Usage Guide
### Creating Your First Grant
#### 1. Choose Your Template
```bash
# For an R01 grant
cp -r templates/R01 my_r01_grant
# For an R03 grant
cp -r templates/R03 my_r03_grant
```
#### 2. Customize Your Grant
Edit the main file (e.g., `my_r01_grant/R01.typ`):
```typst
#import "config.typ": *
#import "../shared/specific_aims.typ": specific_aims_example
#import "../shared/budget.typ": budget_example
// Update with your information
#show: nih-grant.with(
title: "Your Grant Title Here",
pi: "Dr. Your Name",
institution: "Your Institution"
)
// Add your content
#specific_aims[
Your specific aims content here...
]
```
#### 3. Compile Your Grant
```bash
# Using the helper script
./scripts/compile_templates.sh
# Or compile directly with correct root setting
typst compile --root . my_r01_grant/R01.typ outputs/my_r01_grant.pdf
```
### 🔬 Integrating Data Analysis
#### Option 1: R Analysis with Quarto
Create a Quarto document for your analysis:
```r
---
title: "Data Analysis for NIH Grant"
format:
html: default
typst: default
---
```{r}
#| label: fig-results
#| fig-cap: "Primary outcome analysis"
library(ggplot2)
data <- read.csv("data/cleaned/results.csv")
ggplot(data, aes(x = time, y = outcome, color = group)) +
geom_line() +
theme_minimal() +
labs(title = "Treatment Effect Over Time")
ggsave("outputs/figures/primary_outcome.png", dpi = 300)
```
```
Reference in your Typst document:
```typst
#figure(
image("outputs/figures/primary_outcome.png"),
caption: [Treatment effect over time showing significant improvement in the intervention group.]
)
```
#### Option 2: Python Analysis
```python
# scripts/analysis/figures/generate_figures.py
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
# Load and analyze data
data = pd.read_csv('data/cleaned/results.csv')
sns.set_style("whitegrid")
# Create publication-quality figure
fig, ax = plt.subplots(figsize=(8, 6))
sns.lineplot(data=data, x='time', y='outcome', hue='group', ax=ax)
ax.set_title('Treatment Effect Over Time')
plt.savefig('outputs/figures/python_analysis.png', dpi=300, bbox_inches='tight')
```
### 📊 Data Organization
Follow our structured approach for reproducible research:
```
data/
├── raw/ # Never modify these files
│ ├── behavioral/ # Original behavioral data
│ ├── neuroimaging/ # MRI/fMRI data
│ └── clinical/ # Clinical assessments
├── cleaned/ # Processed data with documentation
│ ├── behavioral/ # Analysis-ready datasets
│ └── processing_logs/ # Document all transformations
└── scripts/ # Processing scripts
└── preprocessing/ # Data cleaning code
```
### 📚 Working with References
#### Managing Citations
Add references to `references.bib`:
```bibtex
@article{smith2023example,
title = {Example Study Title},
author = {Smith, Jane and Doe, John},
journal = {Journal of Example Studies},
volume = {42},
pages = {123--456},
year = {2023},
doi = {10.1234/example}
}
```
Cite in Typst:
```typst
Previous research has shown significant effects @smith2023example.
```
#### Format References for NIH
```bash
# Convert to NIH style
python scripts/helpers/reference_formatter.py references.bib --format nih
# Check for duplicates
python scripts/helpers/reference_formatter.py references.bib --check-duplicates
```
### 📝 Creating Progress Reports
Generate professional progress reports using Quarto:
```bash
cd quarto
quarto render progress-report.qmd --to pdf
quarto render progress-report.qmd --to html
```
## 🎨 Available Templates
### R01 - Research Project Grant
- **Purpose**: Major research projects
- **Research Strategy**: 12 pages
- **Budget**: Modular or detailed
- **Duration**: Up to 5 years
- [View template](templates/R01/)
### R03 - Small Grant Program
- **Purpose**: Limited research projects
- **Research Strategy**: 6 pages
- **Budget**: $50,000/year maximum
- **Duration**: Up to 2 years
- [View template](templates/R03/)
### Coming Soon
- R21 - Exploratory/Developmental Research
- K99/R00 - Pathway to Independence
- F31 - Predoctoral Fellowship
## 🛠️ Advanced Features
### VSCode Integration
We include configurations for optimal development:
- Typst syntax highlighting and preview
- Integrated compilation tasks (Ctrl+Shift+B)
- Recommended extensions for R, Python, and Quarto
### Automated Validation
Ensure your grant meets NIH requirements:
```bash
# Check page limits (coming soon)
python scripts/helpers/validate_grant.py outputs/my_grant.pdf --type R01
# Validate formatting
python scripts/helpers/check_formatting.py outputs/my_grant.pdf
```
### Custom Components
Create reusable components for your grants:
```typst
// templates/shared/my_custom_section.typ
#let my_section(content) = {
heading(level: 1, [MY CUSTOM SECTION])
set par(first-line-indent: 0.5in)
content
}
```
## 🤝 Contributing
We welcome contributions! See our [Contributing Guidelines](CONTRIBUTING.md).
### Ways to Contribute
- Add new grant templates
- Improve existing templates
- Share helper scripts
- Enhance documentation
- Report issues
## 📄 License
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
## 🙏 Acknowledgments
- Typst community for the excellent typesetting system
- NIH for grant formatting guidelines
- Contributors who have improved these templates
## 📧 Support
- **Issues**: [GitHub Issues](https://github.com/brainworkup/nih-grant-typst/issues)
- **Discussions**: [GitHub Discussions](https://github.com/brainworkup/nih-grant-typst/discussions)
---
*Remember: Always check the latest NIH guidelines as requirements may change.*