├── .gitignore
├── ChIP_seq
├── call_cluster.py
└── run.zsh
├── LICENSE
├── README.md
├── cellxgene_submission
├── convert_rds_to_h5ad_snATAC.ipynb
├── convert_rds_to_h5ad_visium.ipynb
├── format_snATAC.ipynb
└── format_snRNA.ipynb
├── shiny_apps
├── make_spe_objs_v2.R
└── visium
│ └── AKK001_157785
│ ├── app.R
│ └── www
│ ├── README.md
│ ├── documentation_sce_layer.md
│ ├── documentation_spe.md
│ └── footer.html
├── smfish_analysis
├── LICENSE
├── README.md
├── assign_spots_to_nuclei.Macrophages.Rmd
├── count_spots.run_rsfish.sh
├── count_spots_for_CMs.Rmd
├── get_nuclei_params.py
└── segment_nuclei_smfish_images.sh
├── snATAC_seq
├── data_integration
│ ├── 01_create_project.ipynb
│ ├── 02_quality_check.ipynb
│ ├── 03_create_matrix.ipynb
│ ├── 04_data_integration.ipynb
│ ├── 05_clustering.ipynb
│ ├── 06_annotation.ipynb
│ ├── 07_cell_proportion.ipynb
│ └── 08_viz_marker_gene.ipynb
├── footprinting_analysis
│ ├── DiffFootprintsAllCellTypes
│ │ └── run.sh
│ ├── MotifToGene
│ │ ├── call_cluster.py
│ │ ├── run.zsh
│ │ └── tf_to_gene.py
│ └── SplitBamFilesByCellType
│ │ └── scripts
│ │ ├── CK166.txt
│ │ ├── CK167.txt
│ │ ├── CK168.txt
│ │ ├── CK169.txt
│ │ ├── CK170.txt
│ │ ├── CK171.txt
│ │ ├── CK173.txt
│ │ ├── CK174.txt
│ │ ├── CK336.txt
│ │ ├── CK337.txt
│ │ ├── CK338.txt
│ │ ├── CK339.txt
│ │ ├── CK340.txt
│ │ ├── CK341.txt
│ │ ├── CK343.txt
│ │ ├── CK344.txt
│ │ ├── CK346.txt
│ │ ├── CK349.txt
│ │ ├── CK350.txt
│ │ ├── CK351.txt
│ │ ├── CK352.txt
│ │ ├── CK353.txt
│ │ ├── CK354.txt
│ │ ├── CK355.txt
│ │ ├── CK380.txt
│ │ ├── CK381.txt
│ │ ├── CK382.txt
│ │ ├── CK383.txt
│ │ ├── CK385.txt
│ │ ├── CK386.txt
│ │ ├── CK387.txt
│ │ ├── CK388.txt
│ │ ├── CK389.txt
│ │ ├── CK390.txt
│ │ ├── CK391.txt
│ │ ├── call_cluster.py
│ │ ├── cluster_err
│ │ ├── split_CK166_err.txt
│ │ ├── split_CK167_err.txt
│ │ ├── split_CK168_err.txt
│ │ ├── split_CK169_err.txt
│ │ ├── split_CK170_err.txt
│ │ ├── split_CK171_err.txt
│ │ ├── split_CK173_err.txt
│ │ ├── split_CK174_err.txt
│ │ ├── split_CK336_err.txt
│ │ ├── split_CK337_err.txt
│ │ ├── split_CK338_err.txt
│ │ ├── split_CK339_err.txt
│ │ ├── split_CK340_err.txt
│ │ ├── split_CK341_err.txt
│ │ ├── split_CK343_err.txt
│ │ ├── split_CK344_err.txt
│ │ ├── split_CK346_err.txt
│ │ ├── split_CK349_err.txt
│ │ ├── split_CK350_err.txt
│ │ ├── split_CK351_err.txt
│ │ ├── split_CK352_err.txt
│ │ ├── split_CK353_err.txt
│ │ ├── split_CK354_err.txt
│ │ ├── split_CK355_err.txt
│ │ ├── split_CK380_err.txt
│ │ ├── split_CK381_err.txt
│ │ ├── split_CK382_err.txt
│ │ ├── split_CK383_err.txt
│ │ ├── split_CK385_err.txt
│ │ ├── split_CK386_err.txt
│ │ ├── split_CK387_err.txt
│ │ ├── split_CK388_err.txt
│ │ ├── split_CK389_err.txt
│ │ ├── split_CK390_err.txt
│ │ └── split_CK391_err.txt
│ │ ├── cluster_out
│ │ ├── split_CK166_out.txt
│ │ ├── split_CK167_out.txt
│ │ ├── split_CK168_out.txt
│ │ ├── split_CK169_out.txt
│ │ ├── split_CK170_out.txt
│ │ ├── split_CK171_out.txt
│ │ ├── split_CK173_out.txt
│ │ ├── split_CK174_out.txt
│ │ ├── split_CK336_out.txt
│ │ ├── split_CK337_out.txt
│ │ ├── split_CK338_out.txt
│ │ ├── split_CK339_out.txt
│ │ ├── split_CK340_out.txt
│ │ ├── split_CK341_out.txt
│ │ ├── split_CK343_out.txt
│ │ ├── split_CK344_out.txt
│ │ ├── split_CK346_out.txt
│ │ ├── split_CK349_out.txt
│ │ ├── split_CK350_out.txt
│ │ ├── split_CK351_out.txt
│ │ ├── split_CK352_out.txt
│ │ ├── split_CK353_out.txt
│ │ ├── split_CK354_out.txt
│ │ ├── split_CK355_out.txt
│ │ ├── split_CK380_out.txt
│ │ ├── split_CK381_out.txt
│ │ ├── split_CK382_out.txt
│ │ ├── split_CK383_out.txt
│ │ ├── split_CK385_out.txt
│ │ ├── split_CK386_out.txt
│ │ ├── split_CK387_out.txt
│ │ ├── split_CK388_out.txt
│ │ ├── split_CK389_out.txt
│ │ ├── split_CK390_out.txt
│ │ └── split_CK391_out.txt
│ │ ├── getCluster.R
│ │ └── run.zsh
├── integration_with_snRNA
│ ├── 01_data_integration.ipynb
│ └── 02_evaluation.ipynb
├── mapping_tf_to_space
│ ├── run.zsh
│ └── tf_to_spatial.R
├── peak_to_gene_links
│ ├── 1_p2g_heatmap_celltype.R
│ ├── 1_p2g_heatmap_celltype_reorder_tiff.R
│ ├── README.md
│ ├── chromosome_range.py
│ ├── chromosome_statistic.R
│ ├── detail_corr.py
│ ├── fast_cor_patients.R
│ ├── filter_pval.R
│ ├── findNN_atac.R
│ ├── findNN_rna.R
│ ├── peaks_2_putative_gene.R
│ ├── run_all.py
│ ├── table_add_clusters_each.R
│ └── test_hypothesis.R
├── single_sample
│ ├── 01_label_transfer.Rmd
│ ├── 02_count_matrix.Rmd
│ ├── 03_annotate.Rmd
│ ├── README.md
│ └── pipeline.png
├── tf_gene_association
│ ├── run.zsh
│ └── tf_to_gene.py
└── trajectory_analysis
│ ├── 01_create_arrow_files.Rmd
│ ├── 02_create_archR_project.Rmd
│ ├── 03_dim_reduction.Rmd
│ ├── 04_find_markers.Rmd
│ ├── 05_dm_trajectory.Rmd
│ ├── 06_viz.Rmd
│ └── README.md
└── st_snRNAseq
├── 01.1_spatial_QC_reading
├── compare_deathsign.R
├── run_nucleiquant_qc.R
├── run_qc_diagnostics.R
├── run_singleprocessing_spatial.R
├── run_spark.R
├── run_spark_ora.R
└── visualize_deathsign.R
├── 01_snuc_QC_doublets_majorannotation
├── plot_knownmarkers.R
├── run_qc_diagnostics_snrnaseq.R
├── run_qc_diagnostics_snrnaseq_after_filt.R
└── run_singleprocessing.R
├── 02_snuc_integration_harmony
├── .ipynb_checkpoints
│ ├── BKKNN_integration-checkpoint.ipynb
│ └── hca_markers-checkpoint.ipynb
├── BKKNN_integration.ipynb
├── annotate_clusters.R
├── annotate_object.R
├── get_ct_pbmarkers.R
├── hca_markers.ipynb
├── integrate_objects.R
├── plot_qc.R
├── plot_qc_snrna_pb.R
├── plot_qc_spatial.R
├── plot_qc_spatial_pb.R
└── process_ann_object.R
├── 03_functional_characterization
├── add_funcomics.R
├── add_funcomics_largedata.R
├── estimate_dea.R
├── plot_features.R
├── plot_funcomics.R
└── plot_spatial_progeny.R
├── 04_deconvolution
├── .ipynb_checkpoints
│ ├── Untitled-checkpoint.ipynb
│ ├── Untitled1-checkpoint.ipynb
│ ├── nb_estimates-checkpoint.ipynb
│ ├── nb_estimates-checkpoint.py
│ ├── nb_estimates_mjr-checkpoint.py
│ ├── run_c2l-checkpoint.ipynb
│ ├── run_c2l-checkpoint.py
│ └── untitled-checkpoint.txt
├── add_ct_flags.R
├── add_states.R
├── explore_ct_spatial_umap.R
├── get_inf_aver.R
├── get_states_dea.R
├── locate_wd.py
├── nb_estimates_states_singularity.py
├── nb_to_csvs.py
├── plot_ct_scores.R
└── run_c2l.py
├── 05.1_nicheanalysis
├── .Rapp.history
├── annotate_molecular_markers.R
├── annotate_molecular_markers_myog.R
├── characterize_molniches.R
├── compare_myogenic_ctniches.R
├── describe_pathacts.R
├── generate_spotcelldesc.R
├── plotCMFIB_enrichment.R
├── plotCMFIB_enrichmentv2.R
├── plot_compniche_bars.R
├── plot_molniche_expression.R
├── plot_niche_example.R
└── plt_myogenic_molniches.R
├── 05_colocalization
├── colocalize_misty.R
├── correlate_proportions.R
├── create_niches_ct.R
├── find_niches_ct.R
└── summarize_interactions.R
├── 06_atlas_comparison
├── compare_compositions.R
├── get_pseudobulk_profiles.R
├── make_hca_objs.R
└── pseudobulk_hubner.R
├── 07_structure
├── corr_progeny.R
├── make_misty_ints_panels.R
├── plot_spatial_ex_panels.R
├── plt_niches.R
└── run_misty_pathcrosstalk.R
├── 08_samplecomparison
├── compare_celldependencies.Rmd
├── compare_compositions_momics.R
├── compare_genepatterns.R
├── compare_visium_pbgex.R
├── plot_myogenic_differences.R
└── plot_spatial_examples.R
├── 09_compositionalstability
├── compare_compositions_mi.R
├── get_atac_props.R
├── get_snrna_props.R
└── get_spatial_props.R
├── 10_cellstates
├── .Rapp.history
├── CM
│ ├── compare_ion_channels.R
│ ├── ion_to_state.R
│ ├── plot_stressed.R
│ ├── run_misty_CM_cts.R
│ └── stressed_misty.R
├── Endo
│ ├── compare_spatial_niches.R
│ ├── dissect_misty_results.R
│ └── run_misty_Endo_cts.R
├── Fib
│ ├── dissect_misty_result.R
│ └── run_misty_states_Fib_Myeloid.R
├── Myeloid
│ ├── dissect_misty_results.R
│ └── run_misty_Myeloid_cts.R
├── correlate_spatialmodels.R
├── fetch_annotations.R
└── get_integrated_annobj.R
├── 11_compareATACRNA
├── .Rapp.history
├── compare_tf_acts.R
├── compare_tf_acts_gex.R
├── get_consensus_grn.R
└── get_grns.R
├── 12_probedesign
├── FZ_myeloidfibro.R
└── IZ_myeloidfibro.R
├── 14_cellcomms
├── plt_CM.R
├── plt_endo.R
├── plt_myeloidfib.R
├── plt_pc.R
├── run_liana.R
├── run_liana_adv.R
└── spatial_plts.R
├── 15_imaging
├── quantify_cmstates.R
└── quantify_myeloid.R
├── jobs
├── add_niches.sh
├── c2l_deconv_pt1.sh
├── c2l_deconv_pt2.sh
├── c2l_deconv_pt3.sh
├── c2l_deconv_pt4.sh
├── c2l_nb_states_gpu_singularity.sh
├── estimate_klatlas_markers.sh
├── estimate_snrseqclust_markers.sh
├── estimate_spatial_tfs.sh
├── estimate_visiumclust_markers.sh
├── estimate_visiumclust_markers_ILR.sh
├── estimate_visiumclust_markers_molecular.sh
├── fetch_state_annotations.sh
├── generate_ann_snrnaseq_integrated.sh
├── generate_ann_snrnaseq_integrated_v2.sh
├── generate_ann_snrnaseq_outs.sh
├── generate_ct_niches.sh
├── get_cellcycle_scores.sh
├── get_cellstates.sh
├── get_cellstates_cardio.sh
├── get_cellstates_cardio_filt.sh
├── get_cellstates_endo.sh
├── get_cellstates_endo_filt.sh
├── get_cellstates_fibro.sh
├── get_cellstates_fibro_bis.sh
├── get_cellstates_fibro_filt.sh
├── get_cellstates_immune.sh
├── get_cellstates_lymphoid.sh
├── get_cellstates_lymphoid_filt.sh
├── get_cellstates_macrophages.sh
├── get_cellstates_mirrors.sh
├── get_cellstates_myeloid.sh
├── get_cellstates_myeloid_filt.sh
├── get_cellstates_pericytes.sh
├── get_cellstates_vsmcs.sh
├── get_dfuncs_cardio.sh
├── get_dfuncs_endo.sh
├── get_dfuncs_fibro.sh
├── get_integrated_annobj.sh
├── get_snrna_pseudobulk.sh
├── get_umap.sh
├── klmiatlas_run_pipeline.sh
├── liana_Fib_Myeloid.sh
├── liana_cm.sh
├── liana_endo.sh
├── liana_endo_simple.sh
├── liana_pc.sh
├── liana_pc_simple.sh
├── make_hca_h5admirror.sh
├── make_hca_objs.sh
├── make_snrna_h5admirror.sh
├── make_snrna_h5admirror_raw.sh
├── make_snrna_scemirror.sh
├── make_snrna_scemirror_raw.sh
├── make_visium_scemirror.sh
├── plot_mrks_niches.sh
├── regress_bckground_fibro.sh
├── run_snrnaseq_integration.sh
├── run_snrnaseq_mrkrplt.sh
├── run_spark.sh
├── run_spark.txt
├── run_spatial_integration.sh
├── run_spatial_pseudobulk.sh
├── run_spatial_singleprocessing.sh
├── run_spatial_singleprocessing_unfiltered.sh
├── snatlas_run_pipeline.sh
├── snatlas_run_pipeline_bckground.sh
├── subsample_atlas.sh
└── test_liana.sh
└── utils
├── add_niche_info.R
├── add_niche_info_v2.R
├── c2l_to_R.R
├── cell_map.R
├── copy_c2l.R
├── dea.R
├── funcomics.R
├── h5ad_mirrors.R
├── liana_utils.R
├── loom_mirrors.R
├── map_annotations.R
├── misty_pipeline.R
├── misty_pplne_utils.R
├── misty_utilities.R
├── niche_utils.R
├── pca_utils.R
├── pseudobulk_utils.R
├── sc_plts.R
├── sce_mirrors.R
└── spatial_plots_utils.R
/.gitignore:
--------------------------------------------------------------------------------
1 | .DS_Store
2 | .Rhistory
3 |
--------------------------------------------------------------------------------
/ChIP_seq/call_cluster.py:
--------------------------------------------------------------------------------
1 | import os
2 | import subprocess
3 |
4 | sra_list = ['SRR6426203'] # Adult failing heart
5 | sra_list = ['SRR6426182', 'SRR6426203'] # Adult non-failing heart
6 |
7 | for sra in sra_list:
8 | job_name = sra
9 | subprocess.run(["sbatch", "-J", job_name,
10 | "-o", f"./cluster_out/{job_name}.txt",
11 | "-e", f"./cluster_err/{job_name}.txt",
12 | "--time", "5:00:00",
13 | "--mem", "180G",
14 | "-c", "48",
15 | "-A", "rwth0429",
16 | "run.zsh", sra])
17 |
--------------------------------------------------------------------------------
/ChIP_seq/run.zsh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env zsh
2 |
3 | source ~/.zshrc
4 | conda activate r-heart
5 |
6 | bowtie2_index=/hpcwork/izkf/projects/SingleCellOpenChromatin/local/Bowtie2_indexes/hg38/hg38
7 |
8 | sra=$1
9 |
10 | # download SRA
11 | prefetch $sra
12 |
13 | # Dump each read into separate file. Files will receive suffix corresponding to read number.
14 | fastq-dump -I --split-files $sra
15 | rm -rf $sra
16 |
17 | # Adapter sequences were trimmed from FASTQs
18 | trim_galore --suppress_warn --cores 8 --paired -o ./ ${sra}_1.fastq ${sra}_2.fastq
19 | rm ${sra}_1.fastq
20 | rm ${sra}_2.fastq
21 |
22 | # Map the reads to reference genome
23 | bowtie2 --very-sensitive --no-discordant -x ${bowtie2_index} -1 ${sra}_1_val_1.fq -2 ${sra}_2_val_2.fq -S ${sra}.map.sam -X 2000 -p 50
24 | rm ${sra}_1_val_1.fq
25 | rm ${sra}_2_val_2.fq
26 |
27 | # Filter out reads mapped to chrY, mitochondria, and unassembled "random" contigs,
28 | sed -i '/chrY/d;/chrM/d;/random/d;/chrUn/d' ${sra}.map.sam
29 |
30 | # Convert sam file to bam file, sort the result and generate the index file
31 | samtools view -Sb ${sra}.map.sam > ${sra}.map.bam
32 | samtools sort ${sra}.map.bam -o ${sra}.sort.bam
33 | samtools index ${sra}.sort.bam
34 | rm ${sra}.map.sam
35 | rm ${sra}.map.bam
36 |
37 | # Remove duplicates
38 | java -jar /hpcwork/izkf/jar/picard.jar MarkDuplicates INPUT=${sra}.sort.bam \
39 | OUTPUT=${sra}.rmdup.bam METRICS_FILE=${sra}_matrics.txt REMOVE_DUPLICATES=true VALIDATION_STRINGENCY=LENIENT
40 | rm ${sra}.sort.bam
41 | rm ${sra}.sort.bam.bai
42 |
43 | # and bad map quality
44 | samtools view -bq 30 ${sra}.rmdup.bam > ${sra}.filter.bam
45 | samtools index ${sra}.filter.bam
46 | rm ${sra}.rmdup.bam
47 |
48 | # Require reads to be properly paired
49 | samtools view -f2 ${sra}.filter.bam -b > ${sra}.bam
50 | samtools index ${sra}.bam
51 | samtools flagstat ${sra}.bam > ${sra}_qc.txt
52 |
53 | rm ${sra}.filter.bam
54 | rm ${sra}.filter.bam.bai
55 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | ## Spatial multi-omic map of human myocardial infarction
2 |
3 | Note: This is the code of the revisions of this project
4 |
5 | Cardiovascular diseases, including myocardial infarction are the leading cause of mortality worldwide. After MI, inflammatory and reparative responses trigger widespread myocardial remodeling that affects cardiac function. To fully understand the disease processes it is necessary to describe the heart specific intra- and intercellular signaling mechanisms that coordinate this remodeling.
6 |
7 | Here we present the code used to perform the integrative analysis of single nucleus RNA sequencing (snRNA-seq), single nucleus Assay for Transposase-Accessible Chromatin sequencing (snATAC-seq), and spatial transcriptomics of a collection of human heart patient samples comprising different physiological zones and timepoints of human myocardial infarction and human control myocardium.
8 |
9 | The computational work was motivated by 3 main objectives:
10 |
11 | 1) Provide a single nuclei atlas of the human heart
12 |
13 | 2) Evaluate cell-type molecular and compositional information at increased spatial resolution.
14 |
15 | 3) Explore spatial dependencies between cell-types and molecular processes to generate descriptions of the tissue organization during disease.
16 |
17 | ### Availability of data
18 |
19 | **Exceptions:**
20 | Raw data can't be directly provided at the moment. Processed data will be available in proper data repositories after publication.
21 |
22 | ***
23 |
24 | ### How to cite
25 | > Kuppe C, Ramirez Flores RO, Li Z, et al. “Multi-omic map of human myocardial infarction.” bioRxiv. 2020. DOI: [10.1101/2020.12.08.411686](https://www.biorxiv.org/content/10.1101/2020.12.08.411686v1%20%20)
26 |
27 | To access the code of the bioRxiv please look at the following [tag](https://github.com/saezlab/visium_heart/releases/tag/biorxiv)
28 |
29 |
30 |
31 |
--------------------------------------------------------------------------------
/shiny_apps/visium/AKK001_157785/app.R:
--------------------------------------------------------------------------------
1 | # Copyright (c) [2021] [Ricardo O. Ramirez Flores, Jesus Velez]
2 | # roramirezf@uni-heidelberg.de
3 |
4 | #' Run and deploy spatialLIBD app
5 |
6 | library("spatialLIBD")
7 | library("markdown")
8 |
9 | ## spatialLIBD uses golem
10 | options("golem.app.prod" = TRUE)
11 |
12 | ## You need this to enable shinyapps to install Bioconductor packages
13 | options(repos = BiocManager::repositories())
14 |
15 | ## Load the data
16 | spe <- readRDS("spe_libd.rds")
17 | other_continous <- colnames(colData(spe))
18 | progeny <- other_continous[grepl(pattern = "progeny", other_continous)]
19 | c2l <- other_continous[grepl(pattern = "c2l", other_continous)]
20 |
21 |
22 | ## Deploy the website
23 | spatialLIBD::run_app(
24 | spe,
25 | sce_layer = NULL,
26 | modeling_results = NULL,
27 | sig_genes = NULL,
28 | title = "Specimen AKK001_157785",
29 | spe_discrete_vars = c("label",
30 | "ManualAnnotation",
31 | "opt_clust",
32 | "opt_clust_integrated"),
33 | spe_continuous_vars = c(
34 | "sum_umi",
35 | "sum_gene",
36 | "expr_chrM",
37 | "expr_chrM_ratio",
38 | "sum",
39 | "detected",
40 | "subsets_mito_sum",
41 | "subsets_mito_detected",
42 | "subsets_mito_percent",
43 | "total",
44 | "sizeFactor",
45 | progeny,
46 | c2l
47 | ),
48 | default_cluster = "label",
49 | docs_path = "www"
50 | )
51 |
--------------------------------------------------------------------------------
/shiny_apps/visium/AKK001_157785/www/README.md:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | # Spatial Multiomics Map of Myocardial Infarction
5 |
6 | This website allows to visualize gene expression, pathway activities and cell-type annotations of one slide of 10x Visium spatial transcriptomics.
7 |
8 | Complete documentation of this app can be found in the spot-level tab
9 |
10 | For access to objects used in the original publication, please refer to:
11 |
12 | ## Data transformations
13 |
14 | For visualization purposes, single slides were processed as suggested in the _Visium spatialLIBD workflow_ chapter from _Orchestrating Spatial Transcriptomics Analyses_ (OSTA) with Bioconductor.
15 |
16 | For the same reasons, PCA and UMAP embeddings, and clustering labels are app specific
17 |
18 | However we included the niche labels as: ------
19 |
20 | ## Pathway activities
21 |
22 | _PROGENy_ pathway activity scores can be visualized as a continuous variable if searched with the prefix _progeny_
23 |
24 | ## Deconvolution results
25 |
26 | _cell2location_ scores can be visualized as a continuous variable if searched with the prefix _c2l_
27 |
28 | Deconvolution scores transformed to proportions can be visualized as a continuous variable if searched with the prefix _c2l_props_
29 |
30 |
--------------------------------------------------------------------------------
/shiny_apps/visium/AKK001_157785/www/documentation_sce_layer.md:
--------------------------------------------------------------------------------
1 | Layer-level `spatialLIBD` documentation
2 | =======================================
3 |
4 | Does not apply to the `spatialLIBD` demo in `OSTA`.
5 |
--------------------------------------------------------------------------------
/shiny_apps/visium/AKK001_157785/www/footer.html:
--------------------------------------------------------------------------------
1 | This shiny application is powered by the spatialLIBD
R/Bioconductor package which you can find described in its documentation website.
2 |
3 |
--------------------------------------------------------------------------------
/smfish_analysis/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2022 SchapiroLabor
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/smfish_analysis/README.md:
--------------------------------------------------------------------------------
1 | # Analysis of smFISH data for human myocardial infarction samples
2 |
3 | Docker containers used to run tools for this analysis can be found under the following links:
4 |
5 | * Mesmer: https://hub.docker.com/r/vanvalenlab/deepcell-applications
6 | * RS-FISH: https://hub.docker.com/repository/docker/wuennemannflorian/rs_fish
7 | * Jupyter-Scipy: https://hub.docker.com/r/jupyter/scipy-notebook
8 |
9 | ## Scripts
10 |
11 | * [segment_nuclei_smfish_images.sh](./segment_nuclei_smfish_images.sh) : Used to segment nuclei from smFISH images and compute centroid positions for nuclear masks.
12 | * [count_spots.run_rsfish.sh](./count_spots.run_rsfish.sh) : Run RS-FISH on all .tif images in folder and count RNA spots.
13 | * [count_spots_for_CMs.Rmd](./count_spots_for_CMs.Rmd) : Count spots per image for quantification of NPPB and ANKDR1 signal relative to TNNT2.
14 | * [assign_spots_to_nuclei.Macrophages.Rmd](./assign_spots_to_nuclei.Macrophages.Rmd) : Assign spots from RS-FISH to closest nuclei positions to assign positive cell counts for markers.
15 |
16 |
--------------------------------------------------------------------------------
/smfish_analysis/count_spots.run_rsfish.sh:
--------------------------------------------------------------------------------
1 | ## Run RS-FISH spot counting for all tif images in a given folder
2 | ## threshold and sigma parameters were manually determined for each channel prior to this analysis
3 |
4 | ## binary for bfconvert and channels to process
5 | declare -a channelarray=("1" "2" "3")
6 |
7 | ## Input output dirs for RS-FISH
8 | input="/single_channel_images"
9 | output="/rs_fish_out"
10 |
11 | ## Loop over all ome tiff files in dir
12 | for FILE in *.tif
13 | do
14 | file_base=(${FILE//./ })
15 | file_name=${file_base[0]}
16 | outfile_name_test=$file_name""
17 | if [ ! -f $output/$file_name".ch_"$channel".csv" ]
18 | then
19 | echo $FILE
20 | for channel in ${channelarray[@]}
21 | do
22 | echo $channel
23 |
24 | outfile_name_tif=$file_name".ch_"$channel".tif"
25 | outfile_name_csv=$file_name".ch_"$channel".csv"
26 |
27 | ## Set the parameters for spot counting based on channel
28 | if [ "$channel" == "1" ];
29 | then
30 | set_threshold="0.0222"
31 | set_sigma="2.9"
32 | elif [ "$channel" == "2" ];
33 | then
34 | set_threshold="0.0053"
35 | set_sigma="2.9"
36 | elif [ "$channel" == "3" ];
37 | then
38 | set_threshold="0.0155"
39 | set_sigma="2.9"
40 | echo "channel 3"
41 | fi
42 |
43 | if [ "$channel" != "0" ];
44 | then
45 | ## Run RS-FISH for spot counting
46 | docker run -v $input:/input \
47 | -v $output:/output \
48 | rs_fish:2.3.1 /RS-FISH/rs-fish \
49 | --threshold $set_threshold \
50 | --sigma $set_sigma \
51 | --ransac 1 \
52 | --image=/input/$outfile_name_tif \
53 | --output=/output/$outfile_name_csv
54 | fi
55 | done
56 | else
57 | echo $FILE" is already processed!"
58 | fi
59 | done
60 |
--------------------------------------------------------------------------------
/smfish_analysis/get_nuclei_params.py:
--------------------------------------------------------------------------------
1 | ## Simple script to use skimage to get centroid position of nuclear masks
2 | import imageio
3 | from skimage.measure import label, regionprops, regionprops_table
4 | from skimage import data, filters, measure, morphology
5 | import sys
6 | import pandas as pd
7 |
8 | mask_file = sys.argv[1]
9 | outfile = sys.argv[2]
10 |
11 | mask_im = imageio.imread(mask_file)
12 | labels = measure.label(mask_im)
13 | props = regionprops_table(labels, properties=('centroid',
14 | 'orientation',
15 | 'axis_major_length',
16 | 'axis_minor_length'))
17 | props_df = pd.DataFrame(props)
18 | props_df.to_csv(outfile)
--------------------------------------------------------------------------------
/smfish_analysis/segment_nuclei_smfish_images.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | #SBATCH --partition=single
3 | #SBATCH --ntasks=1
4 | #SBATCH --time=3:00:00
5 | #SBATCH --mem=12gb
6 | #SBATCH --job-name=human_mi
7 | #SBATCH --output=singularity_job-%j.out
8 | #SBATCH --export=NONE
9 |
10 | ## This script will process all Fibroblast-Myeloid RNAscope images from Christoph Kuppe for spot counting and nuclear segmentation
11 |
12 | ## Define parameters
13 | module load system/singularity
14 | module load devel/java_jdk/1.8.0
15 |
16 | singluarity_cache="/home/hd/hd_hd/hd_gr294/singularity_cache"
17 | bfconvert_bin="/home/hd/hd_hd/hd_gr294/bin/bftools/bfconvert"
18 |
19 | project_dir="/gpfs/bwfor/work/ws/hd_gr294/"
20 | orig_image=$project_dir"/original_images"
21 | single_channels=$project_dir"/single_channels"
22 | mesmer_out=$project_dir"/mesmer"
23 | nuclei_tables=$project_dir"/nuclei_tables"
24 |
25 | declare -a channelarray=("0" "1" "2" "3")
26 |
27 | cd $orig_image
28 |
29 | ## Run pipeline
30 | for FILE in *.nd2
31 | do
32 | file_base=(${FILE//./ })
33 | file_name=${file_base[0]}
34 | outfile_name=$file_name"nuclei_params.csv"
35 | if [ ! -f $nuclei_tables/$outfile_name ]
36 | then
37 | echo $FILE
38 | for channel in ${channelarray[@]}
39 | do
40 | echo $channel
41 | outfile_name_tif=$file_name".ch_"$channel".tif"
42 | if [ ! -f $single_channels/$outfile_name_tif ]
43 | then
44 | $bfconvert_bin -channel $channel $orig_image/$FILE $single_channels/$outfile_name_tif
45 | fi
46 | done
47 |
48 | ## Run mesmer nuclear detection
49 | singularity exec -B $single_channels:/input -B $mesmer_out:/output $singluarity_cache/vanvalenlab-deepcell-applications-0.3.0.img python /usr/src/app/run_app.py mesmer --nuclear-image /input/$file_name".ch_0".tif --nuclear-channel 0 --output-directory /output --output-name $file_name".mesmer_nuclear_mask.tif" --compartment nuclear --image-mpp 0.1 --squeeze
50 |
51 | ## Get centroid positions of nuclei from mesmser masks
52 | python_script_dir="/gpfs/bwfor/work/ws/hd_gr294/scripts"
53 | singularity exec -B $mesmer_out:/input -B $nuclei_tables:/output -B $python_script_dir:/scripts $singluarity_cache/jupyter.scipy_notebook_hub.2_1_1.sif python /scripts/get_nuclei_params.py /input/$file_name".mesmer_nuclear_mask.tif" /output/$file_name"nuclei_params.csv"
54 | else
55 | echo $FILE" is already processed!"
56 | fi
57 | done
58 |
--------------------------------------------------------------------------------
/snATAC_seq/footprinting_analysis/MotifToGene/call_cluster.py:
--------------------------------------------------------------------------------
1 | import os
2 | import subprocess
3 |
4 |
5 | ############################
6 | # test
7 | # sample_list = ["CK166"]
8 | ###########################
9 | celltype_list = ['CM', 'Endo', 'Fib', 'Lymphoid', 'Myeloid', 'Pericyte', 'vSMCs']
10 |
11 | for celltype in celltype_list:
12 | job_name = f"{celltype}"
13 | subprocess.run(["sbatch", "-J", job_name,
14 | "-o", f"./cluster_out/{job_name}.txt",
15 | "-e", f"./cluster_err/{job_name}.txt",
16 | "--time", "120:00:00",
17 | "--mem", "180G",
18 | "run.zsh", celltype])
19 |
--------------------------------------------------------------------------------
/snATAC_seq/footprinting_analysis/MotifToGene/run.zsh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/bash
2 |
3 | source ~/.bashrc
4 | conda activate r-4.0.3
5 |
6 |
7 | sed '/var.2/d;/var.3/d' ../DiffFootprintsAllCellTypes/MotifMatching/${1}_mpbs.bed > ./${1}_mpbs.bed
8 | python tf_to_gene.py ./${1}_mpbs.bed ../DiffFootprintsAllCellTypes//BAM/${1}.bam ./${1}.txt
9 | rm ./${1}_mpbs.bed
10 |
--------------------------------------------------------------------------------
/snATAC_seq/footprinting_analysis/MotifToGene/tf_to_gene.py:
--------------------------------------------------------------------------------
1 | import sys
2 | import pandas as pd
3 | from pysam import Samfile
4 | from rgt.GenomicRegionSet import GenomicRegionSet
5 | from rgt.Util import GenomeData
6 |
7 | tf_file = sys.argv[1]
8 | bam_file = sys.argv[2]
9 | output_file = sys.argv[3]
10 |
11 | gr_tfs = GenomicRegionSet(name="TFs")
12 | gr_tfs.read(filename=tf_file)
13 | gr_genes = gr_tfs.gene_association(organism="hg38")
14 |
15 | # Fetching chromosome sizes
16 | genome_data = GenomeData("hg38")
17 | chrom_sizes_file_name = genome_data.get_chromosome_sizes()
18 | chrom_sizes_file = open(chrom_sizes_file_name, "r")
19 | chrom_sizes_dict = dict()
20 | for chrom_sizes_entry_line in chrom_sizes_file:
21 | chrom_sizes_entry_vec = chrom_sizes_entry_line.strip().split("\t")
22 | chrom_sizes_dict[chrom_sizes_entry_vec[0]] = int(chrom_sizes_entry_vec[1])
23 | chrom_sizes_file.close()
24 |
25 | bam = Samfile(bam_file, "rb")
26 |
27 | tf_list = list()
28 | gene_list = list()
29 | tc_list = list()
30 |
31 | for i, r in enumerate(gr_tfs):
32 | tf = r.name.split(".")[-1]
33 | gene = gr_genes[i].name
34 | if gene == "." or "+" in gene or "-" in gene or ":" in gene:
35 | continue
36 |
37 | mid = (r.initial + r.final) / 2
38 | p1 = max(mid - 100, 0)
39 | p2 = min(mid + 100, chrom_sizes_dict[r.chrom])
40 |
41 | iter = bam.fetch(reference=r.chrom, start=p1, end=p2)
42 | tc = 0
43 | for alignment in iter:
44 | tc += 1
45 |
46 | tf_list.append(tf)
47 | gene_list.append(gene)
48 | tc_list.append(tc)
49 |
50 |
51 | df = pd.DataFrame([tf_list, gene_list, tc_list])
52 | df = df.transpose()
53 | df.rename(columns={0: 'TF', 1: 'Gene', 2: 'TC'}, inplace=True)
54 | df = df.groupby(['TF', 'Gene']).sum().reset_index()
55 | df.to_csv(output_file, header=False, index=False, sep='\t')
56 |
--------------------------------------------------------------------------------
/snATAC_seq/footprinting_analysis/SplitBamFilesByCellType/scripts/call_cluster.py:
--------------------------------------------------------------------------------
1 | from __future__ import print_function
2 |
3 | import os
4 | import glob
5 |
6 |
7 | for filename in glob.glob("./CK*.txt"):
8 | base=os.path.basename(filename)
9 | sample = os.path.splitext(base)[0]
10 | job_name = "split_{}".format(sample)
11 | command = "sbatch -J " + job_name + " -o " + "./cluster_out/" + job_name + "_out.txt -e " + \
12 | "./cluster_err/" + job_name + "_err.txt -t 120:00:00 --mem 180G ./run.zsh"
13 | os.system(command + " " + sample)
14 |
--------------------------------------------------------------------------------
/snATAC_seq/footprinting_analysis/SplitBamFilesByCellType/scripts/cluster_err/split_CK166_err.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/KramannLab/visium_heart/03f4cf05328d7ff76ddadc18fcd0cfdbef360909/snATAC_seq/footprinting_analysis/SplitBamFilesByCellType/scripts/cluster_err/split_CK166_err.txt
--------------------------------------------------------------------------------
/snATAC_seq/footprinting_analysis/SplitBamFilesByCellType/scripts/cluster_err/split_CK167_err.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/KramannLab/visium_heart/03f4cf05328d7ff76ddadc18fcd0cfdbef360909/snATAC_seq/footprinting_analysis/SplitBamFilesByCellType/scripts/cluster_err/split_CK167_err.txt
--------------------------------------------------------------------------------
/snATAC_seq/footprinting_analysis/SplitBamFilesByCellType/scripts/cluster_err/split_CK168_err.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/KramannLab/visium_heart/03f4cf05328d7ff76ddadc18fcd0cfdbef360909/snATAC_seq/footprinting_analysis/SplitBamFilesByCellType/scripts/cluster_err/split_CK168_err.txt
--------------------------------------------------------------------------------
/snATAC_seq/footprinting_analysis/SplitBamFilesByCellType/scripts/cluster_err/split_CK169_err.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/KramannLab/visium_heart/03f4cf05328d7ff76ddadc18fcd0cfdbef360909/snATAC_seq/footprinting_analysis/SplitBamFilesByCellType/scripts/cluster_err/split_CK169_err.txt
--------------------------------------------------------------------------------
/snATAC_seq/footprinting_analysis/SplitBamFilesByCellType/scripts/cluster_err/split_CK170_err.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/KramannLab/visium_heart/03f4cf05328d7ff76ddadc18fcd0cfdbef360909/snATAC_seq/footprinting_analysis/SplitBamFilesByCellType/scripts/cluster_err/split_CK170_err.txt
--------------------------------------------------------------------------------
/snATAC_seq/footprinting_analysis/SplitBamFilesByCellType/scripts/cluster_err/split_CK171_err.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/KramannLab/visium_heart/03f4cf05328d7ff76ddadc18fcd0cfdbef360909/snATAC_seq/footprinting_analysis/SplitBamFilesByCellType/scripts/cluster_err/split_CK171_err.txt
--------------------------------------------------------------------------------
/snATAC_seq/footprinting_analysis/SplitBamFilesByCellType/scripts/cluster_err/split_CK173_err.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/KramannLab/visium_heart/03f4cf05328d7ff76ddadc18fcd0cfdbef360909/snATAC_seq/footprinting_analysis/SplitBamFilesByCellType/scripts/cluster_err/split_CK173_err.txt
--------------------------------------------------------------------------------
/snATAC_seq/footprinting_analysis/SplitBamFilesByCellType/scripts/cluster_err/split_CK174_err.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/KramannLab/visium_heart/03f4cf05328d7ff76ddadc18fcd0cfdbef360909/snATAC_seq/footprinting_analysis/SplitBamFilesByCellType/scripts/cluster_err/split_CK174_err.txt
--------------------------------------------------------------------------------
/snATAC_seq/footprinting_analysis/SplitBamFilesByCellType/scripts/cluster_err/split_CK336_err.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/KramannLab/visium_heart/03f4cf05328d7ff76ddadc18fcd0cfdbef360909/snATAC_seq/footprinting_analysis/SplitBamFilesByCellType/scripts/cluster_err/split_CK336_err.txt
--------------------------------------------------------------------------------
/snATAC_seq/footprinting_analysis/SplitBamFilesByCellType/scripts/cluster_err/split_CK337_err.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/KramannLab/visium_heart/03f4cf05328d7ff76ddadc18fcd0cfdbef360909/snATAC_seq/footprinting_analysis/SplitBamFilesByCellType/scripts/cluster_err/split_CK337_err.txt
--------------------------------------------------------------------------------
/snATAC_seq/footprinting_analysis/SplitBamFilesByCellType/scripts/cluster_err/split_CK338_err.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/KramannLab/visium_heart/03f4cf05328d7ff76ddadc18fcd0cfdbef360909/snATAC_seq/footprinting_analysis/SplitBamFilesByCellType/scripts/cluster_err/split_CK338_err.txt
--------------------------------------------------------------------------------
/snATAC_seq/footprinting_analysis/SplitBamFilesByCellType/scripts/cluster_err/split_CK339_err.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/KramannLab/visium_heart/03f4cf05328d7ff76ddadc18fcd0cfdbef360909/snATAC_seq/footprinting_analysis/SplitBamFilesByCellType/scripts/cluster_err/split_CK339_err.txt
--------------------------------------------------------------------------------
/snATAC_seq/footprinting_analysis/SplitBamFilesByCellType/scripts/cluster_err/split_CK340_err.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/KramannLab/visium_heart/03f4cf05328d7ff76ddadc18fcd0cfdbef360909/snATAC_seq/footprinting_analysis/SplitBamFilesByCellType/scripts/cluster_err/split_CK340_err.txt
--------------------------------------------------------------------------------
/snATAC_seq/footprinting_analysis/SplitBamFilesByCellType/scripts/cluster_err/split_CK341_err.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/KramannLab/visium_heart/03f4cf05328d7ff76ddadc18fcd0cfdbef360909/snATAC_seq/footprinting_analysis/SplitBamFilesByCellType/scripts/cluster_err/split_CK341_err.txt
--------------------------------------------------------------------------------
/snATAC_seq/footprinting_analysis/SplitBamFilesByCellType/scripts/cluster_err/split_CK343_err.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/KramannLab/visium_heart/03f4cf05328d7ff76ddadc18fcd0cfdbef360909/snATAC_seq/footprinting_analysis/SplitBamFilesByCellType/scripts/cluster_err/split_CK343_err.txt
--------------------------------------------------------------------------------
/snATAC_seq/footprinting_analysis/SplitBamFilesByCellType/scripts/cluster_err/split_CK344_err.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/KramannLab/visium_heart/03f4cf05328d7ff76ddadc18fcd0cfdbef360909/snATAC_seq/footprinting_analysis/SplitBamFilesByCellType/scripts/cluster_err/split_CK344_err.txt
--------------------------------------------------------------------------------
/snATAC_seq/footprinting_analysis/SplitBamFilesByCellType/scripts/cluster_err/split_CK346_err.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/KramannLab/visium_heart/03f4cf05328d7ff76ddadc18fcd0cfdbef360909/snATAC_seq/footprinting_analysis/SplitBamFilesByCellType/scripts/cluster_err/split_CK346_err.txt
--------------------------------------------------------------------------------
/snATAC_seq/footprinting_analysis/SplitBamFilesByCellType/scripts/cluster_err/split_CK349_err.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/KramannLab/visium_heart/03f4cf05328d7ff76ddadc18fcd0cfdbef360909/snATAC_seq/footprinting_analysis/SplitBamFilesByCellType/scripts/cluster_err/split_CK349_err.txt
--------------------------------------------------------------------------------
/snATAC_seq/footprinting_analysis/SplitBamFilesByCellType/scripts/cluster_err/split_CK350_err.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/KramannLab/visium_heart/03f4cf05328d7ff76ddadc18fcd0cfdbef360909/snATAC_seq/footprinting_analysis/SplitBamFilesByCellType/scripts/cluster_err/split_CK350_err.txt
--------------------------------------------------------------------------------
/snATAC_seq/footprinting_analysis/SplitBamFilesByCellType/scripts/cluster_err/split_CK351_err.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/KramannLab/visium_heart/03f4cf05328d7ff76ddadc18fcd0cfdbef360909/snATAC_seq/footprinting_analysis/SplitBamFilesByCellType/scripts/cluster_err/split_CK351_err.txt
--------------------------------------------------------------------------------
/snATAC_seq/footprinting_analysis/SplitBamFilesByCellType/scripts/cluster_err/split_CK352_err.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/KramannLab/visium_heart/03f4cf05328d7ff76ddadc18fcd0cfdbef360909/snATAC_seq/footprinting_analysis/SplitBamFilesByCellType/scripts/cluster_err/split_CK352_err.txt
--------------------------------------------------------------------------------
/snATAC_seq/footprinting_analysis/SplitBamFilesByCellType/scripts/cluster_err/split_CK353_err.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/KramannLab/visium_heart/03f4cf05328d7ff76ddadc18fcd0cfdbef360909/snATAC_seq/footprinting_analysis/SplitBamFilesByCellType/scripts/cluster_err/split_CK353_err.txt
--------------------------------------------------------------------------------
/snATAC_seq/footprinting_analysis/SplitBamFilesByCellType/scripts/cluster_err/split_CK354_err.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/KramannLab/visium_heart/03f4cf05328d7ff76ddadc18fcd0cfdbef360909/snATAC_seq/footprinting_analysis/SplitBamFilesByCellType/scripts/cluster_err/split_CK354_err.txt
--------------------------------------------------------------------------------
/snATAC_seq/footprinting_analysis/SplitBamFilesByCellType/scripts/cluster_err/split_CK355_err.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/KramannLab/visium_heart/03f4cf05328d7ff76ddadc18fcd0cfdbef360909/snATAC_seq/footprinting_analysis/SplitBamFilesByCellType/scripts/cluster_err/split_CK355_err.txt
--------------------------------------------------------------------------------
/snATAC_seq/footprinting_analysis/SplitBamFilesByCellType/scripts/cluster_err/split_CK380_err.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/KramannLab/visium_heart/03f4cf05328d7ff76ddadc18fcd0cfdbef360909/snATAC_seq/footprinting_analysis/SplitBamFilesByCellType/scripts/cluster_err/split_CK380_err.txt
--------------------------------------------------------------------------------
/snATAC_seq/footprinting_analysis/SplitBamFilesByCellType/scripts/cluster_err/split_CK381_err.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/KramannLab/visium_heart/03f4cf05328d7ff76ddadc18fcd0cfdbef360909/snATAC_seq/footprinting_analysis/SplitBamFilesByCellType/scripts/cluster_err/split_CK381_err.txt
--------------------------------------------------------------------------------
/snATAC_seq/footprinting_analysis/SplitBamFilesByCellType/scripts/cluster_err/split_CK382_err.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/KramannLab/visium_heart/03f4cf05328d7ff76ddadc18fcd0cfdbef360909/snATAC_seq/footprinting_analysis/SplitBamFilesByCellType/scripts/cluster_err/split_CK382_err.txt
--------------------------------------------------------------------------------
/snATAC_seq/footprinting_analysis/SplitBamFilesByCellType/scripts/cluster_err/split_CK383_err.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/KramannLab/visium_heart/03f4cf05328d7ff76ddadc18fcd0cfdbef360909/snATAC_seq/footprinting_analysis/SplitBamFilesByCellType/scripts/cluster_err/split_CK383_err.txt
--------------------------------------------------------------------------------
/snATAC_seq/footprinting_analysis/SplitBamFilesByCellType/scripts/cluster_err/split_CK385_err.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/KramannLab/visium_heart/03f4cf05328d7ff76ddadc18fcd0cfdbef360909/snATAC_seq/footprinting_analysis/SplitBamFilesByCellType/scripts/cluster_err/split_CK385_err.txt
--------------------------------------------------------------------------------
/snATAC_seq/footprinting_analysis/SplitBamFilesByCellType/scripts/cluster_err/split_CK386_err.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/KramannLab/visium_heart/03f4cf05328d7ff76ddadc18fcd0cfdbef360909/snATAC_seq/footprinting_analysis/SplitBamFilesByCellType/scripts/cluster_err/split_CK386_err.txt
--------------------------------------------------------------------------------
/snATAC_seq/footprinting_analysis/SplitBamFilesByCellType/scripts/cluster_err/split_CK387_err.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/KramannLab/visium_heart/03f4cf05328d7ff76ddadc18fcd0cfdbef360909/snATAC_seq/footprinting_analysis/SplitBamFilesByCellType/scripts/cluster_err/split_CK387_err.txt
--------------------------------------------------------------------------------
/snATAC_seq/footprinting_analysis/SplitBamFilesByCellType/scripts/cluster_err/split_CK388_err.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/KramannLab/visium_heart/03f4cf05328d7ff76ddadc18fcd0cfdbef360909/snATAC_seq/footprinting_analysis/SplitBamFilesByCellType/scripts/cluster_err/split_CK388_err.txt
--------------------------------------------------------------------------------
/snATAC_seq/footprinting_analysis/SplitBamFilesByCellType/scripts/cluster_err/split_CK389_err.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/KramannLab/visium_heart/03f4cf05328d7ff76ddadc18fcd0cfdbef360909/snATAC_seq/footprinting_analysis/SplitBamFilesByCellType/scripts/cluster_err/split_CK389_err.txt
--------------------------------------------------------------------------------
/snATAC_seq/footprinting_analysis/SplitBamFilesByCellType/scripts/cluster_err/split_CK390_err.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/KramannLab/visium_heart/03f4cf05328d7ff76ddadc18fcd0cfdbef360909/snATAC_seq/footprinting_analysis/SplitBamFilesByCellType/scripts/cluster_err/split_CK390_err.txt
--------------------------------------------------------------------------------
/snATAC_seq/footprinting_analysis/SplitBamFilesByCellType/scripts/cluster_err/split_CK391_err.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/KramannLab/visium_heart/03f4cf05328d7ff76ddadc18fcd0cfdbef360909/snATAC_seq/footprinting_analysis/SplitBamFilesByCellType/scripts/cluster_err/split_CK391_err.txt
--------------------------------------------------------------------------------
/snATAC_seq/footprinting_analysis/SplitBamFilesByCellType/scripts/cluster_out/split_CK166_out.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/KramannLab/visium_heart/03f4cf05328d7ff76ddadc18fcd0cfdbef360909/snATAC_seq/footprinting_analysis/SplitBamFilesByCellType/scripts/cluster_out/split_CK166_out.txt
--------------------------------------------------------------------------------
/snATAC_seq/footprinting_analysis/SplitBamFilesByCellType/scripts/cluster_out/split_CK167_out.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/KramannLab/visium_heart/03f4cf05328d7ff76ddadc18fcd0cfdbef360909/snATAC_seq/footprinting_analysis/SplitBamFilesByCellType/scripts/cluster_out/split_CK167_out.txt
--------------------------------------------------------------------------------
/snATAC_seq/footprinting_analysis/SplitBamFilesByCellType/scripts/cluster_out/split_CK168_out.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/KramannLab/visium_heart/03f4cf05328d7ff76ddadc18fcd0cfdbef360909/snATAC_seq/footprinting_analysis/SplitBamFilesByCellType/scripts/cluster_out/split_CK168_out.txt
--------------------------------------------------------------------------------
/snATAC_seq/footprinting_analysis/SplitBamFilesByCellType/scripts/cluster_out/split_CK169_out.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/KramannLab/visium_heart/03f4cf05328d7ff76ddadc18fcd0cfdbef360909/snATAC_seq/footprinting_analysis/SplitBamFilesByCellType/scripts/cluster_out/split_CK169_out.txt
--------------------------------------------------------------------------------
/snATAC_seq/footprinting_analysis/SplitBamFilesByCellType/scripts/cluster_out/split_CK170_out.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/KramannLab/visium_heart/03f4cf05328d7ff76ddadc18fcd0cfdbef360909/snATAC_seq/footprinting_analysis/SplitBamFilesByCellType/scripts/cluster_out/split_CK170_out.txt
--------------------------------------------------------------------------------
/snATAC_seq/footprinting_analysis/SplitBamFilesByCellType/scripts/cluster_out/split_CK171_out.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/KramannLab/visium_heart/03f4cf05328d7ff76ddadc18fcd0cfdbef360909/snATAC_seq/footprinting_analysis/SplitBamFilesByCellType/scripts/cluster_out/split_CK171_out.txt
--------------------------------------------------------------------------------
/snATAC_seq/footprinting_analysis/SplitBamFilesByCellType/scripts/cluster_out/split_CK173_out.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/KramannLab/visium_heart/03f4cf05328d7ff76ddadc18fcd0cfdbef360909/snATAC_seq/footprinting_analysis/SplitBamFilesByCellType/scripts/cluster_out/split_CK173_out.txt
--------------------------------------------------------------------------------
/snATAC_seq/footprinting_analysis/SplitBamFilesByCellType/scripts/cluster_out/split_CK174_out.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/KramannLab/visium_heart/03f4cf05328d7ff76ddadc18fcd0cfdbef360909/snATAC_seq/footprinting_analysis/SplitBamFilesByCellType/scripts/cluster_out/split_CK174_out.txt
--------------------------------------------------------------------------------
/snATAC_seq/footprinting_analysis/SplitBamFilesByCellType/scripts/cluster_out/split_CK336_out.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/KramannLab/visium_heart/03f4cf05328d7ff76ddadc18fcd0cfdbef360909/snATAC_seq/footprinting_analysis/SplitBamFilesByCellType/scripts/cluster_out/split_CK336_out.txt
--------------------------------------------------------------------------------
/snATAC_seq/footprinting_analysis/SplitBamFilesByCellType/scripts/cluster_out/split_CK337_out.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/KramannLab/visium_heart/03f4cf05328d7ff76ddadc18fcd0cfdbef360909/snATAC_seq/footprinting_analysis/SplitBamFilesByCellType/scripts/cluster_out/split_CK337_out.txt
--------------------------------------------------------------------------------
/snATAC_seq/footprinting_analysis/SplitBamFilesByCellType/scripts/cluster_out/split_CK338_out.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/KramannLab/visium_heart/03f4cf05328d7ff76ddadc18fcd0cfdbef360909/snATAC_seq/footprinting_analysis/SplitBamFilesByCellType/scripts/cluster_out/split_CK338_out.txt
--------------------------------------------------------------------------------
/snATAC_seq/footprinting_analysis/SplitBamFilesByCellType/scripts/cluster_out/split_CK339_out.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/KramannLab/visium_heart/03f4cf05328d7ff76ddadc18fcd0cfdbef360909/snATAC_seq/footprinting_analysis/SplitBamFilesByCellType/scripts/cluster_out/split_CK339_out.txt
--------------------------------------------------------------------------------
/snATAC_seq/footprinting_analysis/SplitBamFilesByCellType/scripts/cluster_out/split_CK340_out.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/KramannLab/visium_heart/03f4cf05328d7ff76ddadc18fcd0cfdbef360909/snATAC_seq/footprinting_analysis/SplitBamFilesByCellType/scripts/cluster_out/split_CK340_out.txt
--------------------------------------------------------------------------------
/snATAC_seq/footprinting_analysis/SplitBamFilesByCellType/scripts/cluster_out/split_CK341_out.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/KramannLab/visium_heart/03f4cf05328d7ff76ddadc18fcd0cfdbef360909/snATAC_seq/footprinting_analysis/SplitBamFilesByCellType/scripts/cluster_out/split_CK341_out.txt
--------------------------------------------------------------------------------
/snATAC_seq/footprinting_analysis/SplitBamFilesByCellType/scripts/cluster_out/split_CK343_out.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/KramannLab/visium_heart/03f4cf05328d7ff76ddadc18fcd0cfdbef360909/snATAC_seq/footprinting_analysis/SplitBamFilesByCellType/scripts/cluster_out/split_CK343_out.txt
--------------------------------------------------------------------------------
/snATAC_seq/footprinting_analysis/SplitBamFilesByCellType/scripts/cluster_out/split_CK344_out.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/KramannLab/visium_heart/03f4cf05328d7ff76ddadc18fcd0cfdbef360909/snATAC_seq/footprinting_analysis/SplitBamFilesByCellType/scripts/cluster_out/split_CK344_out.txt
--------------------------------------------------------------------------------
/snATAC_seq/footprinting_analysis/SplitBamFilesByCellType/scripts/cluster_out/split_CK346_out.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/KramannLab/visium_heart/03f4cf05328d7ff76ddadc18fcd0cfdbef360909/snATAC_seq/footprinting_analysis/SplitBamFilesByCellType/scripts/cluster_out/split_CK346_out.txt
--------------------------------------------------------------------------------
/snATAC_seq/footprinting_analysis/SplitBamFilesByCellType/scripts/cluster_out/split_CK349_out.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/KramannLab/visium_heart/03f4cf05328d7ff76ddadc18fcd0cfdbef360909/snATAC_seq/footprinting_analysis/SplitBamFilesByCellType/scripts/cluster_out/split_CK349_out.txt
--------------------------------------------------------------------------------
/snATAC_seq/footprinting_analysis/SplitBamFilesByCellType/scripts/cluster_out/split_CK350_out.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/KramannLab/visium_heart/03f4cf05328d7ff76ddadc18fcd0cfdbef360909/snATAC_seq/footprinting_analysis/SplitBamFilesByCellType/scripts/cluster_out/split_CK350_out.txt
--------------------------------------------------------------------------------
/snATAC_seq/footprinting_analysis/SplitBamFilesByCellType/scripts/cluster_out/split_CK351_out.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/KramannLab/visium_heart/03f4cf05328d7ff76ddadc18fcd0cfdbef360909/snATAC_seq/footprinting_analysis/SplitBamFilesByCellType/scripts/cluster_out/split_CK351_out.txt
--------------------------------------------------------------------------------
/snATAC_seq/footprinting_analysis/SplitBamFilesByCellType/scripts/cluster_out/split_CK352_out.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/KramannLab/visium_heart/03f4cf05328d7ff76ddadc18fcd0cfdbef360909/snATAC_seq/footprinting_analysis/SplitBamFilesByCellType/scripts/cluster_out/split_CK352_out.txt
--------------------------------------------------------------------------------
/snATAC_seq/footprinting_analysis/SplitBamFilesByCellType/scripts/cluster_out/split_CK353_out.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/KramannLab/visium_heart/03f4cf05328d7ff76ddadc18fcd0cfdbef360909/snATAC_seq/footprinting_analysis/SplitBamFilesByCellType/scripts/cluster_out/split_CK353_out.txt
--------------------------------------------------------------------------------
/snATAC_seq/footprinting_analysis/SplitBamFilesByCellType/scripts/cluster_out/split_CK354_out.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/KramannLab/visium_heart/03f4cf05328d7ff76ddadc18fcd0cfdbef360909/snATAC_seq/footprinting_analysis/SplitBamFilesByCellType/scripts/cluster_out/split_CK354_out.txt
--------------------------------------------------------------------------------
/snATAC_seq/footprinting_analysis/SplitBamFilesByCellType/scripts/cluster_out/split_CK355_out.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/KramannLab/visium_heart/03f4cf05328d7ff76ddadc18fcd0cfdbef360909/snATAC_seq/footprinting_analysis/SplitBamFilesByCellType/scripts/cluster_out/split_CK355_out.txt
--------------------------------------------------------------------------------
/snATAC_seq/footprinting_analysis/SplitBamFilesByCellType/scripts/cluster_out/split_CK380_out.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/KramannLab/visium_heart/03f4cf05328d7ff76ddadc18fcd0cfdbef360909/snATAC_seq/footprinting_analysis/SplitBamFilesByCellType/scripts/cluster_out/split_CK380_out.txt
--------------------------------------------------------------------------------
/snATAC_seq/footprinting_analysis/SplitBamFilesByCellType/scripts/cluster_out/split_CK381_out.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/KramannLab/visium_heart/03f4cf05328d7ff76ddadc18fcd0cfdbef360909/snATAC_seq/footprinting_analysis/SplitBamFilesByCellType/scripts/cluster_out/split_CK381_out.txt
--------------------------------------------------------------------------------
/snATAC_seq/footprinting_analysis/SplitBamFilesByCellType/scripts/cluster_out/split_CK382_out.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/KramannLab/visium_heart/03f4cf05328d7ff76ddadc18fcd0cfdbef360909/snATAC_seq/footprinting_analysis/SplitBamFilesByCellType/scripts/cluster_out/split_CK382_out.txt
--------------------------------------------------------------------------------
/snATAC_seq/footprinting_analysis/SplitBamFilesByCellType/scripts/cluster_out/split_CK383_out.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/KramannLab/visium_heart/03f4cf05328d7ff76ddadc18fcd0cfdbef360909/snATAC_seq/footprinting_analysis/SplitBamFilesByCellType/scripts/cluster_out/split_CK383_out.txt
--------------------------------------------------------------------------------
/snATAC_seq/footprinting_analysis/SplitBamFilesByCellType/scripts/cluster_out/split_CK385_out.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/KramannLab/visium_heart/03f4cf05328d7ff76ddadc18fcd0cfdbef360909/snATAC_seq/footprinting_analysis/SplitBamFilesByCellType/scripts/cluster_out/split_CK385_out.txt
--------------------------------------------------------------------------------
/snATAC_seq/footprinting_analysis/SplitBamFilesByCellType/scripts/cluster_out/split_CK386_out.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/KramannLab/visium_heart/03f4cf05328d7ff76ddadc18fcd0cfdbef360909/snATAC_seq/footprinting_analysis/SplitBamFilesByCellType/scripts/cluster_out/split_CK386_out.txt
--------------------------------------------------------------------------------
/snATAC_seq/footprinting_analysis/SplitBamFilesByCellType/scripts/cluster_out/split_CK387_out.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/KramannLab/visium_heart/03f4cf05328d7ff76ddadc18fcd0cfdbef360909/snATAC_seq/footprinting_analysis/SplitBamFilesByCellType/scripts/cluster_out/split_CK387_out.txt
--------------------------------------------------------------------------------
/snATAC_seq/footprinting_analysis/SplitBamFilesByCellType/scripts/cluster_out/split_CK388_out.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/KramannLab/visium_heart/03f4cf05328d7ff76ddadc18fcd0cfdbef360909/snATAC_seq/footprinting_analysis/SplitBamFilesByCellType/scripts/cluster_out/split_CK388_out.txt
--------------------------------------------------------------------------------
/snATAC_seq/footprinting_analysis/SplitBamFilesByCellType/scripts/cluster_out/split_CK389_out.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/KramannLab/visium_heart/03f4cf05328d7ff76ddadc18fcd0cfdbef360909/snATAC_seq/footprinting_analysis/SplitBamFilesByCellType/scripts/cluster_out/split_CK389_out.txt
--------------------------------------------------------------------------------
/snATAC_seq/footprinting_analysis/SplitBamFilesByCellType/scripts/cluster_out/split_CK390_out.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/KramannLab/visium_heart/03f4cf05328d7ff76ddadc18fcd0cfdbef360909/snATAC_seq/footprinting_analysis/SplitBamFilesByCellType/scripts/cluster_out/split_CK390_out.txt
--------------------------------------------------------------------------------
/snATAC_seq/footprinting_analysis/SplitBamFilesByCellType/scripts/cluster_out/split_CK391_out.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/KramannLab/visium_heart/03f4cf05328d7ff76ddadc18fcd0cfdbef360909/snATAC_seq/footprinting_analysis/SplitBamFilesByCellType/scripts/cluster_out/split_CK391_out.txt
--------------------------------------------------------------------------------
/snATAC_seq/footprinting_analysis/SplitBamFilesByCellType/scripts/getCluster.R:
--------------------------------------------------------------------------------
1 | library(stringr)
2 | library(ArchR)
3 |
4 | obj.atac <- readRDS("../../../DataIntegration/data/VisiumHeart/snATAC.annotated.Rds")
5 |
6 | df <- obj.atac@meta.data %>%
7 | as.data.frame()
8 |
9 | df <- subset(df, select = c("Sample", "cell_type"))
10 | df$Barcode <- rownames(df)
11 |
12 | # change the barcode suffex
13 | df$Barcode <- stringr::str_split_fixed(df$Barcode, "#", 2)[, 2]
14 |
15 |
16 | for (sample in unique(df$Sample)) {
17 | df_sub <- subset(df, Sample == sample)
18 | df_sub$Sample <- NULL
19 | df_sub <- df_sub[, c("Barcode", "cell_type")]
20 |
21 | write.table(df_sub, file = glue::glue("{sample}.txt"),
22 | row.names = FALSE, sep = "\t", quote = FALSE)
23 |
24 | }
25 |
--------------------------------------------------------------------------------
/snATAC_seq/footprinting_analysis/SplitBamFilesByCellType/scripts/run.zsh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | source ~/.bashrc
4 | conda activate r-4.0.3
5 |
6 | cluster_file=./$1.txt
7 | bam_file=../../../Alignment/$1/outs/possorted_bam.bam
8 | output_location=../BAM
9 |
10 | python ~/scopen/scripts/split_bam_by_cluster.py $cluster_file $bam_file $output_location $1
11 |
--------------------------------------------------------------------------------
/snATAC_seq/mapping_tf_to_space/run.zsh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env zsh
2 | #
3 | #### Job name
4 | #SBATCH -J tf_to_spatial
5 | #SBATCH -e ./tf_to_spatial.txt
6 | #SBATCH -o ./tf_to_spatial.txt
7 | #SBATCH -t 10:00:00
8 | #SBATCH --mem=180G -c 48
9 |
10 | source ~/.zshrc
11 | conda activate r_dorothea
12 |
13 | Rscript tf_to_spatial.R
14 |
--------------------------------------------------------------------------------
/snATAC_seq/peak_to_gene_links/README.md:
--------------------------------------------------------------------------------
1 |
2 | 0. run_all.py ---> run step1 to step12 automatically for all samples
3 | 1. peaks_2_putative_gene.R ---->generate putativie peak-to-gene links
4 | 2. findNN_rna.R ----> find atac nearest rna cell based on coembeding distance
5 | 3. findNN_atac.R ----> find atac top 50 neareast neighbour cells and aggregate these 50 cells for each cell
6 | 4. fast_cor_patients.R ---> calculate the peak-to-gene correlation based on aggregated ATAC matrix and the neighbour RNA matrix
7 | 5. chromosome_range.py ---> based on ordered correlation file generate each chromosome range and peak related genes
8 | 6. chromosome_statistic.R ---> generate a null hypothesis peak-to-gene correlation set for each chromosome
9 | 7. test_hypothesis.R ----> test each peak-to-gene link generate p-value for the null hypothesis.
10 | 8. filter_pval.R ----> remove link padjust-value >=0.5, distance <=2000
11 | 9. 1_p2g_heatmap_celltype.R ---> heatmap for ATAC matrix only, based on significant peak-to-gene links. Column order: put same celltype column(cell) together. Row order: pam clustering based on correlation distance.
12 | 10. 1_p2g_heatmap_celltype_reorder_tiff.R ----> heatmap for ATAC and RNA after rearrange the row cluster order manually.
13 | 11. detail_corr.py ---> add detail info onto the peak-to-gene link csv files.
14 | 12. table_add_clusters_each.R ---> assign celltype annotation for each peak-to-gene link.
15 |
--------------------------------------------------------------------------------
/snATAC_seq/peak_to_gene_links/chromosome_range.py:
--------------------------------------------------------------------------------
1 | from collections import defaultdict
2 |
3 | #f = open("data/peak_annotation_expand_newformat.tsv")
4 |
5 | sample_list = ["CK166", "CK167", "CK168",
6 | "CK170", "CK171", "CK173", "CK174"]
7 |
8 | #sample_list = ["CK166",]
9 |
10 |
11 | #sample_list = ["CK170"]
12 | for sample in sample_list:
13 | f = open("save/corr_%s.tsv" % sample)
14 | f.readline()
15 | last_chromosome = "xxx"
16 |
17 | d = defaultdict(list)
18 | genes_dict = defaultdict(set)
19 |
20 | for idx, line in enumerate(f):
21 | items = line.strip("\n").split("\t")
22 | peak = items[1]
23 | gene = items[2]
24 | chromosome = peak.split(":")[0]
25 | genes_dict[chromosome].add(gene)
26 | if last_chromosome == "xxx":
27 | d[chromosome].append(idx+1)
28 | last_chromosome = chromosome
29 | continue
30 |
31 | if last_chromosome != chromosome and last_chromosome != "xxx":
32 | d[last_chromosome].append(idx)
33 | d[chromosome].append(idx+1)
34 | last_chromosome = chromosome
35 |
36 |
37 | d[chromosome].append(idx)
38 |
39 |
40 | fw = open("save/chromosome_range_%s.txt" % sample, "w")
41 | fw.write("chromosome start end genes\n")
42 | for k, v in d.items():
43 | genes = genes_dict[k]
44 | fw.write("%s %d %d %s\n" %(k, v[0], v[1], ",".join(genes)))
45 | fw.close()
46 |
--------------------------------------------------------------------------------
/snATAC_seq/peak_to_gene_links/detail_corr.py:
--------------------------------------------------------------------------------
1 | from collections import defaultdict
2 | from pathlib import Path
3 | import getopt
4 | import sys
5 |
6 | """
7 | python detail_corr.py
8 | python detail_corr.py -f save/corr_pval_final_0.1.tsv
9 | python detail_corr.py -f save/corr_pval_final_0.2.tsv
10 | python detail_corr.py -f save/corr_pval_final_topn_10000.tsv
11 | python detail_corr.py -f save/corr_pval_final.tsv
12 | python detail_corr.py -f save/corr_pval_filtered.tsv
13 | python detail_corr.py -f save/corr_pval.tsv
14 | """
15 |
16 |
17 | fname = "save/corr_pval_final_0.3.tsv"
18 |
19 | try:
20 | options,args = getopt.getopt(sys.argv[1:],"f:s:")
21 | except getopt.GetoptError:
22 | print("Erorr Parametes")
23 | sys.exit()
24 | for name,value in options:
25 | if name in "-f":
26 | fname = value
27 | print("processing file:", fname)
28 | if name in "-s":
29 | sample = value
30 | print("On:", sample)
31 |
32 |
33 |
34 |
35 | p = Path(fname)
36 | if not p.exists():
37 | print("No this file")
38 | sys.exit()
39 |
40 |
41 | out_file = p.parent / ("detail_%s" % p.name)
42 |
43 | fname_sample = "save/peak2gene_putative_%s.tsv" % sample
44 |
45 | f_sample = open(fname_sample)
46 | sample_first_line = f_sample.readline()
47 |
48 |
49 | f = open(fname)
50 | first_line = f.readline()
51 | other_header = "\t".join(first_line.strip("\n").split("\t")[3:])
52 |
53 | fw = open(out_file, "w")
54 | fw.write("%s\t%s\n" % (sample_first_line.strip("\n"), other_header))
55 |
56 |
57 | d = defaultdict(str)
58 | for line in f_sample:
59 | items_sample = line.strip("\n").split("\t")
60 | peak_gene_sample = items_sample[0:2]
61 | d[tuple(peak_gene_sample)] = "\t".join(items_sample)
62 |
63 |
64 |
65 | for line in f:
66 | items = line.strip("\n").split("\t")
67 | other_info = "\t".join(items[3:])
68 | peak_gene = items[0:2]
69 |
70 | out = d.get(tuple(peak_gene), "")
71 | if not out:
72 | continue
73 | fw.write("%s\t%s\n" % (out, other_info))
74 | fw.close()
75 |
76 |
--------------------------------------------------------------------------------
/snATAC_seq/peak_to_gene_links/filter_pval.R:
--------------------------------------------------------------------------------
1 | library(dplyr)
2 | library(VennDiagram)
3 | #library(RColorBrewer)
4 | library(tidyverse)
5 | library(optparse)
6 | #futile.logger::flog.threshold(futile.logger::ERROR, name = "VennDiagramLogger")
7 |
8 |
9 | parser <- OptionParser()
10 | parser <- add_option(parser, c("-f", "--filter"), type="character", default="0.01",
11 | help="filter pval [default %default]",
12 | metavar="character")
13 |
14 | parser <- add_option(parser, c("-s", "--sample"), type="character", default="CK166",
15 | help="atac name [default %default]",
16 | metavar="character")
17 |
18 | pa = parse_args(parser)
19 |
20 | filter_pval <- as.numeric(pa$filter)
21 | atac_name <- pa$sample
22 |
23 | df <- read.csv(file=sprintf("save/corr_pval_%s.tsv", atac_name), sep = "\t")
24 |
25 | fdf <- df %>% filter(corr>0)
26 | fdf$Sig <- ifelse(fdf$padj<0.05, "TRUE", "FALSE")
27 |
28 | fdf <- fdf %>% filter(fdf$Sig == "TRUE")
29 | write.table(fdf, file=sprintf("save/corr_pval_final_%s.tsv", atac_name),
30 | sep = "\t", quote = F, row.names = F)
31 |
32 | fdf <- fdf %>% filter(fdf$padj% filter(abs(distance) > 2000)
34 | write.table(fdf, file=sprintf("save/corr_pval_final_%s_%.2f.tsv", atac_name, filter_pval),
35 | sep = "\t", quote = F, row.names = F)
36 |
37 |
38 | #df <- read.csv(file=sprintf("save/corr_pval_final_%s_0.01.tsv", atac_name), sep = "\t")
39 | #df <- df %>% filter(df$corr > 0.5)
40 | write.table(df %>% filter(df$corr > 0.3),
41 | file=sprintf("save/corr_pval_final_%s_%.2f_0.3.tsv",atac_name, filter_pval),
42 | sep = "\t", quote = F, row.names = F)
43 |
44 | write.table(df %>% filter(df$corr > 0.5),
45 | file=sprintf("save/corr_pval_final_%s_%.2f_0.5.tsv",atac_name, filter_pval),
46 | sep = "\t", quote = F, row.names = F)
47 |
48 |
49 |
--------------------------------------------------------------------------------
/snATAC_seq/peak_to_gene_links/test_hypothesis.R:
--------------------------------------------------------------------------------
1 | library(dplyr)
2 | library(doParallel)
3 | registerDoParallel(cores=8)
4 |
5 |
6 | ## please add adjust pval to it
7 |
8 |
9 | atac_names = c("CK166", "CK167", "CK168", "CK170", "CK171", "CK173", "CK174")
10 | #atac_names = c("CK167", "CK168")#, "CK171", "CK173", "CK174")
11 | #atac_names = c("CK166")
12 | #atac_names = c("CK166")#, "CK167", "CK168", "CK170", "CK171", "CK173", "CK174")
13 |
14 | foreach(atac_name = atac_names) %dopar%{
15 | message("processing ", atac_name, date())
16 | df <- read.csv(file=sprintf("save/corr_%s.tsv", atac_name), sep="\t", stringsAsFactors = F)
17 | fn = sprintf("save/%s_null_hypothesis.Rds", atac_name)
18 | null_dist_list <- readRDS(file=fn)
19 | stt_vars <- lapply(null_dist_list, function(lst) return(c("mean"=mean(lst), "sd"=sd(lst))))
20 |
21 | #mean_null_coor = 0.1
22 | #sd_null_corr = 0.2
23 | df$pval <- sapply(1:nrow(df), function(x){
24 | chromosome <- strsplit(df[x,]$peak, ":")[[1]][1]
25 | mean_null_corr <- stt_vars[[chromosome]]["mean"]
26 | sd_null_corr <- stt_vars[[chromosome]]["sd"]
27 | 2*pnorm(-abs(((df[x,]$corr - mean_null_corr) / sd_null_corr)))
28 | })
29 |
30 | df$padj <- p.adjust(df$pval, method="BH")
31 |
32 | write.table(df, file=sprintf("save/corr_pval_%s.tsv",atac_name), sep = "\t", quote = F, row.names = F)
33 |
34 | message("finished", atac_name, date())
35 | }
36 |
37 |
--------------------------------------------------------------------------------
/snATAC_seq/single_sample/README.md:
--------------------------------------------------------------------------------
1 | This directory contains R scripts for analysis of scATAC-seq per sample.
2 |
--------------------------------------------------------------------------------
/snATAC_seq/single_sample/pipeline.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/KramannLab/visium_heart/03f4cf05328d7ff76ddadc18fcd0cfdbef360909/snATAC_seq/single_sample/pipeline.png
--------------------------------------------------------------------------------
/snATAC_seq/tf_gene_association/run.zsh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env zsh
2 |
3 | source ~/.zshrc
4 | conda activate r-heart
5 |
6 | sample=$1
7 | celltype=$2
8 |
9 | if [ -f ../HINT/DiffFootprintsPerSample/${sample}/MotifMatching/${celltype}_mpbs.bed ];then
10 | # sed '/var.2/d;/var.3/d;/::/d' ../HINT/DiffFootprintsPerSample/${sample}/MotifMatching/${celltype}_mpbs.bed > ./${sample}/${celltype}_mpbs.bed
11 | sed '/var.2/d;/var.3/d' ../HINT/DiffFootprintsPerSample/${sample}/MotifMatching/${celltype}_mpbs.bed > ./${sample}/${celltype}_mpbs.bed
12 | python tf_to_gene.py ./${sample}/${celltype}_mpbs.bed ../HINT/DiffFootprintsPerSample/${sample}/BAM/${celltype}.bam ./${sample}/${celltype}.txt
13 | rm ./${sample}/${celltype}_mpbs.bed
14 | fi
15 |
--------------------------------------------------------------------------------
/snATAC_seq/tf_gene_association/tf_to_gene.py:
--------------------------------------------------------------------------------
1 | import sys
2 | import pandas as pd
3 | from pysam import Samfile
4 | from rgt.GenomicRegionSet import GenomicRegionSet
5 | from rgt.Util import GenomeData
6 |
7 | tf_file = sys.argv[1]
8 | bam_file = sys.argv[2]
9 | output_file = sys.argv[3]
10 |
11 | gr_tfs = GenomicRegionSet(name="TFs")
12 | gr_tfs.read(filename=tf_file)
13 | gr_genes = gr_tfs.gene_association(organism="hg38")
14 |
15 | # Fetching chromosome sizes
16 | genome_data = GenomeData("hg38")
17 | chrom_sizes_file_name = genome_data.get_chromosome_sizes()
18 | chrom_sizes_file = open(chrom_sizes_file_name, "r")
19 | chrom_sizes_dict = dict()
20 | for chrom_sizes_entry_line in chrom_sizes_file:
21 | chrom_sizes_entry_vec = chrom_sizes_entry_line.strip().split("\t")
22 | chrom_sizes_dict[chrom_sizes_entry_vec[0]] = int(chrom_sizes_entry_vec[1])
23 | chrom_sizes_file.close()
24 |
25 | bam = Samfile(bam_file, "rb")
26 |
27 | tf_list = list()
28 | gene_list = list()
29 | tc_list = list()
30 |
31 | for i, r in enumerate(gr_tfs):
32 | tf = r.name.split(".")[-1]
33 | gene = gr_genes[i].name
34 | if gene == "." or "+" in gene or "-" in gene or ":" in gene:
35 | continue
36 |
37 | mid = (r.initial + r.final) / 2
38 | p1 = max(mid - 100, 0)
39 | p2 = min(mid + 100, chrom_sizes_dict[r.chrom])
40 |
41 | iter = bam.fetch(reference=r.chrom, start=p1, end=p2)
42 | tc = 0
43 | for alignment in iter:
44 | tc += 1
45 |
46 | tf_list.append(tf)
47 | gene_list.append(gene)
48 | tc_list.append(tc)
49 |
50 |
51 | df = pd.DataFrame([tf_list, gene_list, tc_list])
52 | df = df.transpose()
53 | df.rename(columns={0: 'TF', 1: 'Gene', 2: 'TC'}, inplace=True)
54 | df = df.groupby(['TF', 'Gene']).sum().reset_index()
55 | df.to_csv(output_file, header=False, index=False, sep='\t')
56 |
--------------------------------------------------------------------------------
/snATAC_seq/trajectory_analysis/01_create_arrow_files.Rmd:
--------------------------------------------------------------------------------
1 | ---
2 | title: "Analyze data using ArchR"
3 | author: "Zhijian Li"
4 | date: '`r format(Sys.Date(), "%Y-%B-%d")`'
5 | output: html_document
6 | ---
7 |
8 | ```{r setup, include=FALSE}
9 | library(ggplot2)
10 | library(stringr)
11 | library(magrittr)
12 | library(WriteXLS)
13 | library(tidyr)
14 | library(dplyr)
15 | library(plotly)
16 | library(cluster)
17 | library(cowplot)
18 | library(gridExtra)
19 | library(viridis)
20 | library(GenomicRanges)
21 | library(GenomeInfoDb)
22 | library(data.table)
23 | library(ArchR)
24 | ```
25 |
26 | ```{r set_parameters, echo=FALSE}
27 | ## set parameters
28 | set.seed(42)
29 | addArchRThreads(threads = 1)
30 | addArchRGenome("hg38")
31 | ```
32 |
33 | ## Reading barcodes
34 | ```{r}
35 | message("Reading in integrated data...")
36 | heart.integrated <- readRDS("../../ATAC_Integration/data/heart.integrated.Rds")
37 | meta_data <- heart.integrated@meta.data
38 | print(colnames(meta_data))
39 |
40 | fib_meta_data <- subset(meta_data, celltype %in% c("Fibroblasts 0",
41 | "Fibroblasts 1",
42 | "Fibroblasts 2",
43 | "Fibroblasts 3",
44 | "Fibroblasts 5"))
45 |
46 |
47 | ```
48 |
49 |
50 | ## Creating Arrow Files
51 | ```{r}
52 | inputFiles <- c("Heart" = "../../Aggregation/Heart/outs/fragments.tsv.gz")
53 |
54 | minTSS <- 1
55 | minFrags <- 100
56 |
57 | ArrowFiles <- createArrowFiles(
58 | inputFiles = inputFiles,
59 | sampleNames = names(inputFiles),
60 | outputNames = names(inputFiles),
61 | validBarcodes = rownames(fib_meta_data),
62 | minTSS = minTSS,
63 | minFrags = minFrags,
64 | maxFrags = 1e+07,
65 | QCDir = "QualityControl",
66 | addTileMat = TRUE,
67 | addGeneScoreMat = TRUE
68 | )
69 |
70 | ArrowFiles
71 | ```
72 |
73 |
74 | ## Session information
75 | ```{r}
76 | sessionInfo()
77 | ```
78 |
--------------------------------------------------------------------------------
/snATAC_seq/trajectory_analysis/README.md:
--------------------------------------------------------------------------------
1 | This directory contains R scripts for fibroblasts trajectory analysis using snATAC-seq.
2 |
--------------------------------------------------------------------------------
/st_snRNAseq/01.1_spatial_QC_reading/run_qc_diagnostics.R:
--------------------------------------------------------------------------------
1 | # Copyright (c) [2021] [Ricardo O. Ramirez Flores]
2 | # roramirezf@uni-heidelberg.de
3 |
4 | #' In this script we run the basic QC analysis of samples from their
5 | #' spaceranger diagnostics
6 | #' folder
7 | #' |
8 | #' sample---outs
9 | #' |
10 | #' ---spatial
11 | #' ---filtered_feature_bc_matrix.h5
12 |
13 | library(tidyverse)
14 | library(cowplot)
15 |
16 | path <- "./visium_data/"
17 |
18 | qc_feats <- c("sample_names",
19 | "Number of Spots Under Tissue",
20 | "Median Genes per Spot",
21 | "Mean Reads per Spot",
22 | "Fraction Reads in Spots Under Tissue",
23 | "Median UMI Counts per Spot",
24 | "Fraction of Spots Under Tissue",
25 | "Fraction Reads in Spots Under Tissue")
26 |
27 | sample_names <- list.files(path)
28 |
29 | slide_files <- paste0(path,
30 | sample_names,
31 | "/outs/metrics_summary.csv")
32 |
33 | qc_stats <- tibble(sample_names,
34 | qc_stats = map(slide_files, read_csv)) %>%
35 | unnest() %>%
36 | dplyr::select(all_of(qc_feats))
37 |
38 | qc_stats_plts <- qc_stats %>%
39 | pivot_longer(-sample_names, names_to = "qc_feature") %>%
40 | group_by(qc_feature) %>%
41 | nest() %>%
42 | mutate(qc_plt = map2(qc_feature, data, function(dat_label, dat) {
43 |
44 | ggplot(dat, aes(x = sample_names,
45 | y = value)) +
46 | geom_bar(stat = "identity") +
47 | theme_classic() +
48 | theme(axis.text.x = element_text(angle = 90, hjust =1, vjust =0.5),
49 | axis.text = element_text(size = 12),
50 | axis.title.y = element_text(size = 13)) +
51 | xlab("") + ylab(dat_label)
52 |
53 |
54 | }))
55 |
56 | all_panels <- cowplot::plot_grid(plotlist = qc_stats_plts$qc_plt, align = "vh", ncol = 1)
57 |
58 | pdf(height = 25, width = 20, file = "./processed_visium/initial_qc/all_qcs.pdf")
59 |
60 | plot(all_panels)
61 |
62 | dev.off()
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
--------------------------------------------------------------------------------
/st_snRNAseq/01_snuc_QC_doublets_majorannotation/run_qc_diagnostics_snrnaseq.R:
--------------------------------------------------------------------------------
1 | # Copyright (c) [2021] [Ricardo O. Ramirez Flores]
2 | # roramirezf@uni-heidelberg.de
3 |
4 | #' In this script we run the basic QC analysis of samples from their
5 | #' spaceranger diagnostics
6 | #' folder
7 | #' |
8 | #' sample---outs
9 | #' |
10 | #' ---spatial
11 | #' ---filtered_feature_bc_matrix.h5
12 |
13 | library(tidyverse)
14 | library(cowplot)
15 |
16 | path <- "./snrnaseq_data/"
17 |
18 | qc_feats <- c("sample_names",
19 | "Estimated Number of Cells",
20 | "Mean Reads per Cell",
21 | "Median Genes per Cell",
22 | "Fraction Reads in Cells",
23 | "Total Genes Detected",
24 | "Median UMI Counts per Cell")
25 |
26 | sample_names <- list.files(path)
27 |
28 | slide_files <- paste0(path,
29 | sample_names,
30 | "/outs/metrics_summary.csv")
31 |
32 | qc_stats <- tibble(sample_names,
33 | qc_stats = map(slide_files, read_csv)) %>%
34 | unnest() %>%
35 | dplyr::select(all_of(qc_feats))
36 |
37 | qc_stats$`Fraction Reads in Cells` <- gsub("%", "", qc_stats$`Fraction Reads in Cells`) %>%
38 | as.numeric()
39 |
40 | qc_stats_plts <- qc_stats %>%
41 | pivot_longer(-sample_names, names_to = "qc_feature") %>%
42 | group_by(qc_feature) %>%
43 | nest() %>%
44 | mutate(qc_plt = map2(qc_feature, data, function(dat_label, dat) {
45 |
46 | ggplot(dat, aes(x = sample_names,
47 | y = value)) +
48 | geom_bar(stat = "identity") +
49 | theme_classic() +
50 | theme(axis.text.x = element_text(angle = 90, hjust =1, vjust =0.5),
51 | axis.text = element_text(size = 12),
52 | axis.title.y = element_text(size = 13)) +
53 | xlab("") + ylab(dat_label)
54 |
55 |
56 | }))
57 |
58 | all_panels <- cowplot::plot_grid(plotlist = qc_stats_plts$qc_plt, align = "vh", ncol = 1)
59 |
60 | pdf(height = 20, width = 17, file = "./processed_snrnaseq/initial_qc/all_qcs.pdf")
61 |
62 | plot(all_panels)
63 |
64 | dev.off()
65 |
66 | qc_stats[, c("sample_names",
67 | "Estimated Number of Cells",
68 | "Mean Reads per Cell",
69 | "Median Genes per Cell")] %>%
70 | write.table(row.names = F, col.names = T, quote = F, sep = ",",
71 | file = "./processed_snrnaseq/initial_qc/all_qcs.csv")
72 |
--------------------------------------------------------------------------------
/st_snRNAseq/01_snuc_QC_doublets_majorannotation/run_qc_diagnostics_snrnaseq_after_filt.R:
--------------------------------------------------------------------------------
1 | # Copyright (c) [2021] [Ricardo O. Ramirez Flores]
2 | # roramirezf@uni-heidelberg.de
3 |
4 | #' In this script we recover the QC stats of all slides
5 | #' after individual processing
6 |
7 | library(tidyverse)
8 | library(Seurat)
9 |
10 | folder = T
11 | path = "./processed_snrnaseq/objects/"
12 | sample_names <- list.files(path)
13 | sample_names <- gsub("[.]rds", "", sample_names)
14 | slide_files <- set_names(paste0(path, sample_names, ".rds"), sample_names)
15 |
16 | qc_afetr_filt <- map(slide_files, function(rds_file) {
17 | print(rds_file)
18 | visium_slide_meta <- readRDS(rds_file)@meta.data %>%
19 | group_by(orig.ident) %>%
20 | summarise(n_cell_after_filt = length(orig.ident),
21 | median_counts = median(nCount_RNA),
22 | median_ngenes = median(nFeature_RNA))
23 |
24 | return(visium_slide_meta)
25 |
26 | }) %>%
27 | enframe("sample_id") %>%
28 | unnest() %>%
29 | dplyr::select(-orig.ident) %>%
30 | write.table(row.names = F, col.names = T, quote = F, sep = ",",
31 | file = "./processed_snrnaseq/initial_qc/all_qcs_after_processing.csv")
32 |
--------------------------------------------------------------------------------
/st_snRNAseq/03_functional_characterization/plot_spatial_progeny.R:
--------------------------------------------------------------------------------
1 | # Copyright (c) [2021] [Ricardo O. Ramirez Flores]
2 | # roramirezf@uni-heidelberg.de
3 |
4 | #' In this script I plot progeny scores for all slides
5 |
6 | path <- "./processed_visium/objects/"
7 | outpath <- "./results/progeny/spatial/"
8 | slide_files <- list.files(path)
9 | slide_names <- gsub("[.]rds", "", slide_files)
10 |
11 | param_df <- tibble(slide_name = slide_names,
12 | slide_file = paste0(path, slide_files),
13 | slide_out = paste0(outpath, slide_files %>% gsub("[.]rds", "_progenyplts.pdf",.)))
14 |
15 | plt_spatialprogeny <- function(slide_name, slide_file, slide_out) {
16 |
17 | print(slide_name)
18 |
19 | visium_slide <- readRDS(slide_file)
20 |
21 | DefaultAssay(visium_slide) <- "progeny"
22 |
23 | pdf(slide_out, height = 20, width = 16)
24 |
25 | prog_plt <- SpatialFeaturePlot(visium_slide,
26 | features = rownames(visium_slide),
27 | ncol = 4)
28 |
29 | plot(prog_plt)
30 |
31 | dev.off()
32 |
33 | }
34 |
35 | pwalk(param_df, plt_spatialprogeny)
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
--------------------------------------------------------------------------------
/st_snRNAseq/04_deconvolution/.ipynb_checkpoints/Untitled-checkpoint.ipynb:
--------------------------------------------------------------------------------
1 | {
2 | "cells": [],
3 | "metadata": {},
4 | "nbformat": 4,
5 | "nbformat_minor": 4
6 | }
7 |
--------------------------------------------------------------------------------
/st_snRNAseq/04_deconvolution/.ipynb_checkpoints/Untitled1-checkpoint.ipynb:
--------------------------------------------------------------------------------
1 | {
2 | "cells": [],
3 | "metadata": {},
4 | "nbformat": 4,
5 | "nbformat_minor": 4
6 | }
7 |
--------------------------------------------------------------------------------
/st_snRNAseq/04_deconvolution/.ipynb_checkpoints/untitled-checkpoint.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/KramannLab/visium_heart/03f4cf05328d7ff76ddadc18fcd0cfdbef360909/st_snRNAseq/04_deconvolution/.ipynb_checkpoints/untitled-checkpoint.txt
--------------------------------------------------------------------------------
/st_snRNAseq/04_deconvolution/add_ct_flags.R:
--------------------------------------------------------------------------------
1 | # Copyright (c) [2021] [Ricardo O. Ramirez Flores]
2 | # roramirezf@uni-heidelberg.de
3 |
4 | #' Here we add cell-type flags to denote where a given cell type may be located
5 |
6 | library(Seurat)
7 | library(tidyverse)
8 |
9 | # Import path pointers
10 |
11 | # Get individual slide info ---------------------------------------------
12 | visium_folder = "./processed_visium/objects/"
13 | visium_files <- list.files(visium_folder, full.names = F)
14 | visium_samples <- gsub("[.]rds", "", visium_files)
15 | visium_df <- tibble(visium_file = paste0(visium_folder,
16 | visium_files),
17 | sample = visium_samples)
18 |
19 | # First for each slide we will create metavariables that flag the location of a cell-type in a spot
20 |
21 | c2l_assay <- "c2l_props"
22 |
23 | # Eveything except cardiomyocytes and fibroblast must represent 10% of celltype score
24 | ct_prop_param <- tibble(cts = c("CM", "Fib", "Endo", "Myeloid", "Mast")) %>%
25 | mutate(prop_param = 0.125)
26 |
27 | add_ct_flags <- function(slide, ct_prop_param, cell_props) {
28 |
29 | for(ct in ct_prop_param$cts) {
30 |
31 | ix <- grepl(ct, ct_prop_param$cts)
32 |
33 | prop_param <- ct_prop_param$prop_param[ix]
34 |
35 | slide[[paste0(ct,"_flag")]] = ifelse(cell_props[, ct] <= prop_param, 0, 1)
36 |
37 | }
38 |
39 | return(slide)
40 |
41 | }
42 |
43 | walk(visium_df$visium_file, function(visium_file) {
44 |
45 | print(visium_file)
46 |
47 | slide <- readRDS(visium_file)
48 | cell_props <- GetAssayData(slide, assay = c2l_assay) %>% t()
49 |
50 | slide_ct_prop_param <- ct_prop_param %>%
51 | dplyr::filter(cts %in% colnames(cell_props))
52 |
53 | slide <- add_ct_flags(slide = slide,
54 | ct_prop_param = slide_ct_prop_param,
55 | cell_props = cell_props)
56 |
57 | saveRDS(slide, file = visium_file)
58 |
59 | })
60 |
61 |
62 |
63 |
--------------------------------------------------------------------------------
/st_snRNAseq/04_deconvolution/add_states.R:
--------------------------------------------------------------------------------
1 | # Copyright (c) [2021] [Ricardo O. Ramirez Flores]
2 | # roramirezf@uni-heidelberg.de
3 |
4 | #' Add module score of gene sets of cellular states from
5 | #' get_states_dea.R
6 |
7 | library(Seurat)
8 | library(tidyverse)
9 | source("./analysis/utils/funcomics.R")
10 |
11 | # Main
12 |
13 | # Get individual slide info ---------------------------------------------
14 | visium_folder = "./processed_visium/objects/"
15 |
16 | visium_files <- list.files(visium_folder, full.names = F)
17 | visium_samples <- gsub("[.]rds", "", visium_files)
18 |
19 | visium_df <- tibble(visium_file = paste0(visium_folder,
20 | visium_files),
21 | sample = visium_samples) %>%
22 | mutate()
23 |
24 | # Add module score ---------------------------------------------
25 | gsets <- readRDS(file = "./results/ct_data/state_genesets.rds")
26 | gsets_list <- readRDS(file = "./results/ct_data/state_genesets_list.rds")
27 |
28 | walk(visium_df$visium_file, function(visium_file) {
29 | print(visium_file)
30 |
31 | visium_slide <- readRDS(visium_file) %>%
32 | get_wmean_score(visium_slide = .,
33 | network = gsets,
34 | assay = "SCT",
35 | module_name = "cell_states")
36 |
37 | #visium_slide <- getTF_matrix_MS(visium_slide,
38 | # MS_regulon = gsets_list,
39 | # assay = "SCT",
40 | # module_name = "cell_states_ms")
41 |
42 | saveRDS(visium_slide, file = visium_file)
43 | })
44 |
45 | # Add GRN data
46 |
47 | # cm_grn <- read_csv("./results/ct_regnets/CM/gene_cluster.csv") %>%
48 | # dplyr::select(gene, cluster) %>%
49 | # dplyr::rename("source" = cluster,
50 | # "target" = gene) %>%
51 | # dplyr::mutate(likelihood = 1,
52 | # mor = 1,
53 | # source = paste0("CM_", source))
54 | #
55 | # walk(visium_df$visium_file, function(visium_file) {
56 | # print(visium_file)
57 | #
58 | # visium_slide <- readRDS(visium_file) %>%
59 | # get_wmean_score(visium_slide = .,
60 | # network = cm_grn,
61 | # assay = "SCT",
62 | # module_name = "cell_states_rn")
63 | #
64 | # saveRDS(visium_slide, file = visium_file)
65 | # })
66 |
--------------------------------------------------------------------------------
/st_snRNAseq/04_deconvolution/get_inf_aver.R:
--------------------------------------------------------------------------------
1 | # Copyright (c) [2021] [Ricardo O. Ramirez Flores]
2 | # roramirezf@uni-heidelberg.de
3 |
4 | #' From cell2location estimates, get a summarized inferred average
5 | #'
6 |
7 | library(tidyverse)
8 |
9 | nb_estimates_folder <- "./results/nb_estimates_csv/"
10 | nb_files <- set_names(paste0(nb_estimates_folder ,
11 | list.files(nb_estimates_folder)),
12 | paste0("iter_", seq(1,5,1)))
13 |
14 | nb_mats <- map(nb_files, function(x) {
15 | read_csv(x, col_names = T) %>%
16 | dplyr::rename("gene" = X1)
17 | })
18 |
19 |
20 | nb_mats <- nb_mats %>%
21 | enframe() %>%
22 | unnest() %>%
23 | pivot_longer(-c(name, gene),
24 | names_to = "cell_type",
25 | values_to = "infer_aver")
26 |
27 |
28 | map(set_names(nb_mats$cell_type %>% unique), function(ct) {
29 |
30 | ct_dat <- nb_mats %>%
31 | dplyr::filter(cell_type == ct) %>%
32 | dplyr::select(-cell_type) %>%
33 | pivot_wider(values_from = infer_aver,
34 | names_from = name,
35 | values_fill = NA) %>%
36 | column_to_rownames("gene") %>%
37 | as.matrix() %>%
38 | na.omit()
39 |
40 | cor_ct_dat <- cor(ct_dat)
41 |
42 | mean(cor_ct_dat[upper.tri(cor_ct_dat,diag = F)])
43 |
44 | }) %>% enframe() %>%
45 | unnest() %>%
46 | ggplot(aes(x = value, y = name)) +
47 | geom_bar(stat = "identity")
48 |
49 |
50 | # Final data
51 |
52 | nb_mats <- nb_mats %>%
53 | mutate(cell_type = gsub("-", "_", cell_type)) %>%
54 | group_by(gene, cell_type) %>%
55 | summarize(mean_infer_aver = mean(infer_aver)) %>%
56 | ungroup() %>%
57 | pivot_wider(names_from = cell_type, values_from = mean_infer_aver) %>%
58 | column_to_rownames("gene")
59 |
60 | write.csv(nb_mats, file = paste0(nb_estimates_folder, "mean_infer_aver.csv"), row.names = T, col.names = T, quote = F)
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
--------------------------------------------------------------------------------
/st_snRNAseq/04_deconvolution/get_states_dea.R:
--------------------------------------------------------------------------------
1 | # Copyright (c) [2021] [Ricardo O. Ramirez Flores]
2 | # roramirezf@uni-heidelberg.de
3 |
4 | #' Here we create a dictionary of gene_sets associated with states
5 | #' The differeentially expressed genes are coming from the
6 | #' funcomics pipeline
7 |
8 | library(tidyverse)
9 |
10 | # These are the markers of the cell-states
11 | state_mrkrs <- tibble(marker_file = list.files("./cell_states", full.names = T)) %>%
12 | dplyr::mutate(cell_type = gsub("./cell_states/", "", marker_file)) %>%
13 | dplyr::mutate(marker_file = paste0(marker_file,"/annotation.rds")) %>%
14 | dplyr::mutate(markers = map(marker_file, readRDS)) %>%
15 | dplyr::select(cell_type, markers) %>%
16 | unnest() %>%
17 | dplyr::select(cell_type, p_val_adj, cluster, gene, avg_log2FC) %>%
18 | dplyr::filter(p_val_adj < 0.05) %>%
19 | dplyr::select(-p_val_adj) %>%
20 | mutate(source = paste0(cell_type, "_", cluster),
21 | mor = sign(avg_log2FC)) %>%
22 | dplyr::rename("target" = gene,
23 | "likelihood" = avg_log2FC) %>%
24 | dplyr::select(-c("cell_type", "cluster"))
25 |
26 | # I will ignore all state mrkrs that have less than 50 markers
27 | state_mrkrs <- state_mrkrs %>%
28 | group_by(source) %>%
29 | nest() %>%
30 | dplyr::mutate(n_mrkrs = map(data, nrow)) %>%
31 | #dplyr::filter(n_mrkrs >= 50) %>%
32 | dplyr::select(-n_mrkrs) %>%
33 | dplyr::filter(! grepl("Adipo", source),
34 | ! grepl("Mast", source)) %>%
35 | unnest() %>%
36 | ungroup()
37 |
38 | saveRDS(state_mrkrs, file = "./results/ct_data/state_genesets.rds")
39 |
40 | # Make a list of markers for the module score estimation
41 |
42 | state_mrkrs_list <- state_mrkrs %>%
43 | dplyr::select(source, target) %>%
44 | dplyr::group_by(source) %>%
45 | nest() %>%
46 | dplyr::mutate(data = map(data, ~ .x[[1]])) %>%
47 | deframe()
48 |
49 | saveRDS(state_mrkrs_list, file = "./results/ct_data/state_genesets_list.rds")
50 |
51 |
--------------------------------------------------------------------------------
/st_snRNAseq/04_deconvolution/locate_wd.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python
2 | # coding: utf-8
3 |
4 | import sys
5 | import scanpy as sc
6 | import anndata
7 | import pandas as pd
8 | import numpy as np
9 | import os
10 | import gc
11 |
12 | data_type = 'float32'
13 | os.environ["THEANO_FLAGS"] = 'device=cuda,floatX=' + data_type + ',force_device=True'
14 |
15 | import cell2location
16 | import matplotlib as mpl
17 | from matplotlib import rcParams
18 | import matplotlib.pyplot as plt
19 | import seaborn as sns
20 |
21 | # silence scanpy that prints a lot of warnings
22 | import warnings
23 | warnings.filterwarnings('ignore')
24 |
25 | print(os.getcwd())
--------------------------------------------------------------------------------
/st_snRNAseq/04_deconvolution/nb_to_csvs.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python
2 | # coding: utf-8
3 |
4 | # In[1]:
5 |
6 |
7 | #!/usr/bin/env python
8 | # coding: utf-8
9 | import sys
10 | import scanpy as sc
11 | import anndata
12 | import pandas as pd
13 | import numpy as np
14 | import os
15 | import gc
16 | data_type = 'float32'
17 |
18 |
19 | # In[29]:
20 |
21 |
22 | # Here we will define the path location of all nb models
23 |
24 | # Set paths to data and results used through the document:
25 | reg_data_folder = '/Users/ricardoramirez/Dropbox/PhD/Research/mi_atlas/results/nb_estimates/'
26 | reg_data_folder_out = '/Users/ricardoramirez/Dropbox/PhD/Research/mi_atlas/results/nb_estimates_csv/'
27 | nb_folders = [f for f in os.listdir(reg_data_folder) if os.path.isdir(reg_data_folder + f)]
28 | nb_out = [reg_data_folder + f + "/sc.h5ad" for f in nb_folders]
29 |
30 |
31 | # In[15]:
32 |
33 |
34 | def get_infer_average(nb_file):
35 | # First generate the reference data frame
36 | adata_snrna_raw = sc.read(nb_file)
37 | # Column name containing cell type annotations
38 | covariate_col_names = 'cell_type'
39 | # Extract a pd.DataFrame with signatures from anndata object
40 | inf_aver = adata_snrna_raw.raw.var.copy()
41 | inf_aver = inf_aver.loc[:, [f'means_cov_effect_{covariate_col_names}_{i}' for i in adata_snrna_raw.obs[covariate_col_names].unique()]]
42 | from re import sub
43 | inf_aver.columns = [sub(f'means_cov_effect_{covariate_col_names}_{i}', '', i) for i in adata_snrna_raw.obs[covariate_col_names].unique()]
44 | inf_aver = inf_aver.iloc[:, inf_aver.columns.argsort()]
45 | # normalise by average experiment scaling factor (corrects for sequencing depth)
46 | inf_aver = inf_aver * adata_snrna_raw.uns['regression_mod']['post_sample_means']['sample_scaling'].mean()
47 | # eliminate duplicates in inf aver too just in case
48 | x = pd.Series([i for i in inf_aver.index.values])
49 | inf_aver = inf_aver.iloc[~x.duplicated(keep = "first").values,]
50 | return(inf_aver)
51 |
52 |
53 | # In[23]:
54 |
55 |
56 | inf_aver_list = {i: get_infer_average(nb_out[i]) for i in range(0,5)}
57 |
58 |
59 | # In[30]:
60 |
61 |
62 | for i in range(0,5):
63 | inf_aver_list[i].to_csv(reg_data_folder_out + nb_folders[i] + ".csv")
64 |
65 |
66 | # In[19]:
67 |
68 |
69 |
70 |
71 |
72 | # In[28]:
73 |
74 |
75 |
76 |
77 |
78 | # In[ ]:
79 |
80 |
81 |
82 |
83 |
--------------------------------------------------------------------------------
/st_snRNAseq/04_deconvolution/plot_ct_scores.R:
--------------------------------------------------------------------------------
1 | # Copyright (c) [2021] [Ricardo O. Ramirez Flores]
2 | # roramirezf@uni-heidelberg.de
3 |
4 | #' Plot the c2l plots to have a visual representation of the cells
5 |
6 | library(Seurat)
7 | library(tidyverse)
8 | library(cowplot)
9 |
10 | visium_folder = "./processed_visium/objects/"
11 | out_folder_abundance = "results/deconvolution_models/plots/abundance/"
12 | out_folder_proportion = "results/deconvolution_models/plots/proportion/"
13 |
14 | visium_files <- list.files(visium_folder, full.names = F)
15 | visium_samples <- gsub("[.]rds", "", visium_files)
16 |
17 | assay_names <- set_names(c("c2l", "c2l_props"))
18 |
19 | SpatialPal = colorRampPalette(rev(RColorBrewer::brewer.pal(11, 'Spectral')))
20 |
21 | visium_df <- tibble(visium_file = paste0(visium_folder,
22 | visium_files),
23 | sample = visium_samples)
24 |
25 | walk2(visium_df$visium_file, visium_df$sample, function(f_path, s) {
26 |
27 | print(s)
28 |
29 | visium_slide <- readRDS(f_path)
30 |
31 | assay_plots <- map(assay_names, function(assay_name){
32 |
33 | features <- rownames(GetAssayData(visium_slide,
34 | slot = "data",
35 | assay = assay_name))
36 |
37 | DefaultAssay(visium_slide) <- assay_name
38 |
39 | feat_plots <- map(features, function(spec_f) {
40 |
41 | f_p <- SpatialFeaturePlot(visium_slide,
42 | features = spec_f)
43 |
44 | if(grepl(pattern = "props", assay_name)) {
45 | f_p <- f_p +
46 | scale_fill_gradientn(colours = SpatialPal(length(seq(0,1,.1))),
47 | limits = c(0,1),
48 | breaks = c(0, 0.25, 0.5, 0.75, 1))
49 | }
50 |
51 | return(f_p)
52 |
53 | })
54 |
55 | niche_plots <- plot_grid(plotlist = feat_plots, ncol = 4)
56 |
57 | })
58 |
59 | # Plot abundances
60 |
61 | abundance_f <- paste0(out_folder_abundance, s,".pdf")
62 |
63 | pdf(file = abundance_f, width = 15, height = 15)
64 |
65 | plot(assay_plots[[1]])
66 |
67 | dev.off()
68 |
69 | prop_f <- paste0(out_folder_proportion, s,".pdf")
70 |
71 | pdf(file = prop_f, width = 15, height = 15)
72 |
73 | plot(assay_plots[[2]])
74 |
75 | dev.off()
76 |
77 | })
78 |
--------------------------------------------------------------------------------
/st_snRNAseq/05.1_nicheanalysis/.Rapp.history:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/KramannLab/visium_heart/03f4cf05328d7ff76ddadc18fcd0cfdbef360909/st_snRNAseq/05.1_nicheanalysis/.Rapp.history
--------------------------------------------------------------------------------
/st_snRNAseq/05.1_nicheanalysis/plot_compniche_bars.R:
--------------------------------------------------------------------------------
1 | # Copyright (c) [2022] [Ricardo O. Ramirez Flores]
2 | # roramirezf@uni-heidelberg.de
3 |
4 | # In this script I will generate the stacked barplots of the compositional niches
5 |
6 |
7 | library(Seurat)
8 | library(tidyverse)
9 | library(viridis)
10 | source("./analysis/utils/spatial_plots_utils.R")
11 |
12 |
13 | niche_cols <- list(niche_1 = "#D51F26",
14 | niche_2 = "#272E6A",
15 | niche_3 = "#208A42",
16 | niche_4 = "#89288F",
17 | niche_5 = "#F47D2B",
18 | niche_6 = "#FEE500",
19 | niche_7 = "#8A9FD1",
20 | niche_8 = "#C06CAB",
21 | niche_9 = "#D8A767") %>%
22 | unlist()
23 |
24 |
25 | niche_props <- "./results/niche_mapping/composition_niche/niche_props.csv" %>%
26 | read_csv()
27 |
28 | niche_props_plt <- ggplot(niche_props,aes(x = patient_region_id, y = niche_prop, fill = mol_niche)) +
29 | geom_bar(position = "stack", stat = "identity") +
30 | theme_classic() +
31 | theme(axis.text.x = element_text(angle = 45, size = 10,
32 | hjust = 1),
33 | axis.text.y = element_text(size = 10)) +
34 | scale_fill_manual(values = niche_cols) +
35 | ylab("") +
36 | xlab("")
37 |
38 | pdf("./results/niche_mapping/composition_niche/niche_props_bars.pdf", height = 4, width = 7)
39 |
40 | plot(niche_props_plt)
41 |
42 | dev.off()
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
--------------------------------------------------------------------------------
/st_snRNAseq/05.1_nicheanalysis/plot_molniche_expression.R:
--------------------------------------------------------------------------------
1 | library(tidyverse)
2 | library(Seurat)
3 |
4 |
5 | ctrls <- read_csv("./markers/visium_patient_anns_revisions.csv") %>%
6 | dplyr::filter(major_labl == "CTRL") %>%
7 | pull(sample_id)
8 |
9 | walk(ctrls, function(slide_id) {
10 |
11 | slide_file <- paste0("./processed_visium/objects/", slide_id, ".rds")
12 | pdf_file <- paste0("./results/niche_mapping/Spatial_snn_res.0.2/myogenic_gene_plots/", slide_id)
13 |
14 | visium_slide <- readRDS(slide_file)
15 |
16 | DefaultAssay(visium_slide) <- "SCT"
17 |
18 | walk(c("MYBPC3", "ANKRD2", "RYR2"), function(g){
19 |
20 | plt <- SpatialFeaturePlot(visium_slide, features = g,max.cutoff = "q99", min.cutoff = "q1")
21 |
22 | pdf(paste0(pdf_file,"_CTRL", "_", g, ".pdf"), height = 4, width = 4)
23 |
24 | plot(plt)
25 |
26 | dev.off()
27 |
28 | })
29 |
30 |
31 | })
32 |
33 | bzs <- read_csv("./markers/visium_patient_anns_revisions.csv") %>%
34 | dplyr::filter(major_labl == "BZ") %>%
35 | pull(sample_id)
36 |
37 | walk(bzs, function(slide_id) {
38 |
39 | slide_file <- paste0("./processed_visium/objects/", slide_id, ".rds")
40 | pdf_file <- paste0("./results/niche_mapping/Spatial_snn_res.0.2/myogenic_gene_plots/", slide_id)
41 |
42 | visium_slide <- readRDS(slide_file)
43 |
44 | DefaultAssay(visium_slide) <- "SCT"
45 |
46 | walk(c("MYBPC3", "ANKRD2", "RYR2"), function(g){
47 |
48 | plt <- SpatialFeaturePlot(visium_slide, features = g,max.cutoff = "q99", min.cutoff = "q1")
49 |
50 | pdf(paste0(pdf_file,"_bz", "_", g, ".pdf"), height = 4, width = 4)
51 |
52 | plot(plt)
53 |
54 | dev.off()
55 |
56 | })
57 |
58 |
59 | })
60 |
61 | visium_slide <- readRDS("./processed_visium/objects/AKK002_157781.rds") %>%
62 | positive_states(., assay = state_origin) %>%
63 | filter_states(slide = .,
64 | by_prop = F,
65 | prop_thrsh = 0.1)
66 |
67 |
68 |
69 | SpatialFeaturePlot(visium_slide,c("CCDC80", "TMSB10"))
70 |
71 |
72 |
73 |
--------------------------------------------------------------------------------
/st_snRNAseq/05.1_nicheanalysis/plt_myogenic_molniches.R:
--------------------------------------------------------------------------------
1 | # Copyright (c) [2022] [Ricardo O. Ramirez Flores]
2 | # roramirezf@uni-heidelberg.de
3 |
4 | #' Visualize trends of niche composition
5 | library(tidyverse)
6 | library(ComplexHeatmap)
7 |
8 | pat_anns <- read_csv("./markers/visium_patient_anns_revisions.csv")
9 |
10 | niche_props <- read_csv("results/niche_mapping/Spatial_snn_res.0.2/niche_props.csv") %>%
11 | left_join(pat_anns)
12 |
13 | pw_test_res <- read_csv("results/niche_mapping/Spatial_snn_res.0.2/niche_props_pwtest_area_myogenic.csv")
14 |
15 | niche_props <- niche_props %>%
16 | dplyr::filter(patient_group == "group_1",
17 | major_labl %in% c("BZ", "CTRL", "RZ"),
18 | mol_niche %in% pw_test_res$mol_niche) %>%
19 | group_by(mol_niche, major_labl) %>%
20 | summarize(mean_prop = mean(niche_prop)) %>%
21 | group_by(mol_niche) %>%
22 | dplyr::mutate(std_mean_prop = (mean_prop - mean(mean_prop))/sd(mean_prop)) %>%
23 | dplyr::filter(mol_niche %in% c("niche_0", "niche_1", "niche_3"))
24 |
25 | myogenic_niche_plt <- niche_props %>%
26 | dplyr::select(-mean_prop) %>%
27 | pivot_wider(names_from = major_labl, values_from = std_mean_prop) %>%
28 | column_to_rownames("mol_niche") %>%
29 | as.matrix() %>%
30 | ComplexHeatmap::Heatmap(.,name = "std mean prop")
31 |
32 | pdf("results/niche_mapping/Spatial_snn_res.0.2/niche_props_myogenic.pdf", height = 3,width = 4)
33 |
34 | draw(myogenic_niche_plt)
35 |
36 | dev.off()
37 |
38 | niche_props %>% write_csv("results/niche_mapping/Spatial_snn_res.0.2/niche_props_myogenic.csv")
39 |
--------------------------------------------------------------------------------
/st_snRNAseq/05_colocalization/correlate_proportions.R:
--------------------------------------------------------------------------------
1 | # Copyright (c) [2021] [Ricardo O. Ramirez Flores]
2 | # roramirezf@uni-heidelberg.de
3 |
4 | #' Correlate cell2location results from all slides
5 | #'
6 | library(tidyverse)
7 | library(ComplexHeatmap)
8 |
9 | c2l_folder <- "./results/deconvolution_models/location_models/density_tables_rds/"
10 |
11 | # Get cell2location files --------------------------------
12 | c2l_files <- list.files(c2l_folder, full.names = F)
13 |
14 | c2l_samples <- map_chr(strsplit(c2l_files,".rds"),
15 | ~ .x[1])
16 |
17 | c2l_df <- tibble(c2l_file = paste0(c2l_folder,
18 | c2l_files),
19 | sample = c2l_samples)
20 |
21 | # Generates list of matrix of c2l results
22 | list_matrices <- map2(c2l_df$c2l_file, c2l_df$sample, function(f, s) {
23 | mat <- readRDS(f)
24 | rownames(mat) <- paste0(s, "..", rownames(mat))
25 | prop_mat <- base::apply(mat, 1, function(x) {
26 |
27 | x/sum(x)
28 |
29 | })
30 |
31 | return(t(prop_mat))
32 | })
33 |
34 | integrated_compositions <- reduce(list_matrices, rbind)
35 |
36 | cor_mat <- cor(integrated_compositions)
37 | cor_mat_order <- hclust(as.dist(1-cor_mat))
38 | cor_mat_order <- cor_mat_order$labels[cor_mat_order$order]
39 |
40 | cor_mat <- cor_mat[cor_mat_order,cor_mat_order]
41 |
42 | cor_mat[lower.tri(cor_mat,diag = T)] <- NA
43 |
44 | cor_plt_dat <- cor_mat %>%
45 | as.data.frame() %>%
46 | rownames_to_column("cell_a") %>%
47 | pivot_longer(-cell_a, values_to = "p_corr", names_to = "cell_b") %>%
48 | na.omit() %>%
49 | dplyr::mutate(cell_a = factor(cell_a,
50 | levels = cor_mat_order),
51 | cell_b = factor(cell_b,
52 | levels = cor_mat_order))
53 |
54 |
55 | cor_plt <- ggplot(cor_plt_dat, aes(x = cell_a, y = cell_b, fill = p_corr)) +
56 | geom_tile() +
57 | theme_classic() +
58 | theme(axis.text.x = element_text(angle = 90, hjust = 1, vjust =0.5),
59 | axis.text = element_text(size = 12)) +
60 | scale_fill_gradient2() +
61 | coord_equal()
62 |
63 | pdf("./results/tissue_structure/colocalization/c2l_correlation.pdf", height = 4, width = 5)
64 |
65 | plot(cor_plt)
66 |
67 | dev.off()
68 |
--------------------------------------------------------------------------------
/st_snRNAseq/06_atlas_comparison/make_hca_objs.R:
--------------------------------------------------------------------------------
1 | # Copyright (c) [2021] [Ricardo O. Ramirez Flores]
2 | # roramirezf@uni-heidelberg.de
3 |
4 | #' In this script we reduce HCA object to obtain nuclei and LV
5 | library(Seurat)
6 | library(SingleCellExperiment)
7 | library(zellkonverter)
8 | library(tidyverse)
9 |
10 | hca_atlas <- readRDS("./ext_data/hca_seurat.rds")
11 |
12 | lv_atlas <- subset(hca_atlas, subset = region == "LV" &
13 | source == "Nuclei" &
14 | Used == "Yes" &
15 | cell_type != "doublets")
16 |
17 | rm(hca_atlas)
18 |
19 | saveRDS(lv_atlas, file = "./ext_data/hca_seurat_lv.rds")
20 |
21 | print("seurat done")
22 |
23 | # as single cell experiment
24 | colnames(lv_atlas@meta.data) <- gsub("[.]", "_", colnames(lv_atlas@meta.data))
25 | lv_atlas_sce <- as.SingleCellExperiment(lv_atlas)
26 | saveRDS(lv_atlas_sce, file = "./ext_data/hca_sce_lv.rds")
27 |
28 | print("sce done")
29 |
30 | # scanpy ready
31 | writeH5AD(lv_atlas_sce, file = "./ext_data/hca_lv.h5ad")
32 |
33 | print("h5ad done")
34 |
--------------------------------------------------------------------------------
/st_snRNAseq/07_structure/corr_progeny.R:
--------------------------------------------------------------------------------
1 | # Copyright (c) [2022] [Ricardo O. Ramirez Flores]
2 | # roramirezf@uni-heidelberg.de
3 |
4 | #' Correlate PROGENy scores with each other
5 |
6 | library(Seurat)
7 | library(tidyverse)
8 |
9 | # Main
10 |
11 | # Get individual slide info ---------------------------------------------
12 | visium_folder = "./processed_visium/objects/"
13 |
14 | visium_files <- list.files(visium_folder, full.names = F)
15 | visium_samples <- gsub("[.]rds", "", visium_files)
16 |
17 | visium_df <- tibble(visium_file = paste0(visium_folder,
18 | visium_files),
19 | sample = visium_samples) %>%
20 | mutate()
21 |
22 | all_cors <- map(set_names(visium_df$visium_file, visium_df$sample), function(visium_file) {
23 | print(visium_file)
24 |
25 | path_score <- readRDS(visium_file) %>%
26 | GetAssayData(., assay = "progeny") %>%
27 | as.matrix() %>%
28 | t() %>%
29 | cor()
30 |
31 | return(path_score)
32 | })
33 |
34 | all_cors_df <- map(all_cors, function(x) {
35 |
36 | x %>%
37 | as.data.frame() %>%
38 | rownames_to_column("feature_a") %>%
39 | pivot_longer(-feature_a, names_to = "feature_b")
40 |
41 |
42 | }) %>% enframe() %>%
43 | unnest()
44 |
45 | progeny_cors_plt <- all_cors_df %>%
46 | group_by(feature_a, feature_b) %>%
47 | summarise(mean_cor = mean(value)) %>%
48 | ggplot(., aes(x = feature_a, y = feature_b, fill = mean_cor)) +
49 | geom_tile() +
50 | scale_fill_gradient2() +
51 | theme(axis.text.x = element_text(angle = 90, hjust = 1, vjust =0.5),
52 | axis.text = element_text(size = 12)) +
53 | xlab("") +
54 | ylab("") +
55 | coord_equal()
56 |
57 | pdf("./results/tissue_structure/progeny_cors.pdf", height = 5, width = 5)
58 |
59 | plot(progeny_cors_plt)
60 |
61 | dev.off()
62 |
63 |
64 |
--------------------------------------------------------------------------------
/st_snRNAseq/08_samplecomparison/plot_myogenic_differences.R:
--------------------------------------------------------------------------------
1 | # Copyright (c) [2020] [Ricardo O. Ramirez Flores]
2 | # roramirezf@uni-heidelberg.de
3 |
4 | library(Seurat)
5 | library(tidyverse)
6 |
7 | sel_niches <- c("niche_0",
8 | "niche_1",
9 | "niche_3")
10 |
11 | pat_anns <- read_csv("./markers/visium_patient_anns_revisions.csv")
12 |
13 | niche_props <- read_csv("./results/niche_mapping/Spatial_snn_res.0.2/niche_props.csv") %>%
14 | left_join(pat_anns) %>%
15 | dplyr::filter(mol_niche %in% sel_niches,
16 | patient_group == "group_1") %>%
17 | arrange(mol_niche, -niche_prop)
18 |
19 | # Plot examples
20 |
21 | slide_name <- c("Visium_6_CK284", "AKK003_157777", "AKK002_157781", "Visium_8_CK286")
22 | features = c("MYBPC3","ANKRD2")
23 |
24 | for(s in slide_name) {
25 |
26 | print(s)
27 |
28 | visium_slide <- readRDS(paste0("./processed_visium/objects/", s, ".rds"))
29 |
30 | DefaultAssay(visium_slide) <- "SCT"
31 |
32 | for(f in features) {
33 |
34 | pdf(paste0("./results/niche_mapping/Spatial_snn_res.0.2/myogenic_gene_plots/", s,"_",f, ".pdf"), height = 4.5, width = 4)
35 |
36 | plot(SpatialFeaturePlot(visium_slide, features = f))
37 |
38 | dev.off()
39 | }
40 |
41 |
42 | }
43 |
--------------------------------------------------------------------------------
/st_snRNAseq/09_compositionalstability/get_atac_props.R:
--------------------------------------------------------------------------------
1 | # Copyright (c) [2021] [Ricardo O. Ramirez Flores]
2 | # roramirezf@uni-heidelberg.de
3 |
4 | #' Here we estimate cell compositions from ATAC
5 | library(tidyverse)
6 |
7 | # ATAC data meta --------------------------------------------------------------------------
8 | atac_ann <- readRDS("./markers/atac_patient_anns_revisions.rds")
9 |
10 | atac_meta <- read.csv("./processed_atac/metadata.csv") %>%
11 | dplyr::select(X, orig.ident, cell_type) %>%
12 | left_join(atac_ann, by = c("orig.ident" = "sample_id"))# Then fix the annotations ussing the updated table
13 |
14 |
15 | # Generate cell type counts -----------------------------------------------------------
16 | atac_props <- atac_meta %>%
17 | group_by(patient_id, cell_type) %>%
18 | summarize(atac_n_cells = length(patient_id)) %>%
19 | mutate(atac_prop_cells = atac_n_cells/sum(atac_n_cells)) %>%
20 | dplyr::mutate(cell_type = gsub("-","_", cell_type)) %>%
21 | dplyr::mutate(cell_type = ifelse(cell_type == "Pericyte", "PC", cell_type)) %>%
22 | dplyr::mutate(cell_type = ifelse(cell_type == "neuronal", "Neuronal", cell_type))
23 |
24 | write.table(atac_props, file = "./results/compositions/atac_compositions.txt", col.names = T, row.names = F, quote = F, sep = "\t")
25 |
26 | atac_props$keep <- ifelse((atac_props$atac_n_cells > 10),
27 | TRUE, FALSE)
28 |
29 | cols <- c("TRUE" = "grey",
30 | "FALSE" = "black")
31 |
32 | # First check the number of cells per patient
33 | patient_summary_plt_flx <- ggplot(atac_props,
34 | aes(y = patient_id, x = cell_type, fill = keep)) +
35 | geom_tile() +
36 | theme_classic() +
37 | theme(axis.text.x = element_text(angle = 90, hjust = 1, vjust = 0.5),
38 | panel.background= element_rect(fill="black", colour="black")) +
39 | scale_fill_manual(values = cols,
40 | na.value = 'black') +
41 | coord_equal()
42 |
43 | pdf("./results/cell_markers/cell_type_recovery_atac.pdf", height = 5, width = 4)
44 |
45 | plot(patient_summary_plt_flx)
46 |
47 | dev.off()
48 |
--------------------------------------------------------------------------------
/st_snRNAseq/09_compositionalstability/get_snrna_props.R:
--------------------------------------------------------------------------------
1 | # Copyright (c) [2021] [Ricardo O. Ramirez Flores]
2 | # roramirezf@uni-heidelberg.de
3 |
4 | #' Here we estimate cell compositions from snRNAseq
5 | library(tidyverse)
6 |
7 | # Scell data meta --------------------------------------------------------------------------
8 | scell_meta <- readRDS("./processed_snrnaseq/integration/ps_integrated_rnasamples_ann.rds")[[1]][["annotations"]]
9 | snrna_anns <- readRDS("./markers/snrna_patient_anns_revisions.rds")
10 |
11 | # Generate cell type counts -----------------------------------------------------------
12 | scell_props <- scell_meta %>%
13 | left_join(snrna_anns, by = c("orig.ident" = "sample_id")) %>%
14 | group_by(patient_id, cell_type) %>%
15 | summarize(sn_n_cells = length(patient_id)) %>%
16 | mutate(sn_prop_cells = sn_n_cells/sum(sn_n_cells)) %>%
17 | dplyr::mutate(cell_type = gsub("-","_", cell_type))
18 |
19 | write.table(scell_props, file = "./results/compositions/snrna_compositions.txt", col.names = T, row.names = F, quote = F, sep = "\t")
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/st_snRNAseq/09_compositionalstability/get_spatial_props.R:
--------------------------------------------------------------------------------
1 | # Copyright (c) [2021] [Ricardo O. Ramirez Flores]
2 | # roramirezf@uni-heidelberg.de
3 |
4 | #' Here we estimate cell compositions from visium
5 |
6 | library(tidyverse)
7 | library(Seurat)
8 |
9 | # Get all data files -----------------------------------------------------------------------
10 | slide_files_folder <- "./results/deconvolution_models/location_models/density_tables_rds/"
11 | slide_files <- list.files(slide_files_folder)
12 | slide_files_full <- paste0(slide_files_folder,
13 | slide_files)
14 | slide_ids <- gsub("[.]rds", "", slide_files)
15 |
16 | # Patient annotation -------------------------------------------------------------------------
17 | visium_anns <- readRDS("./markers/visium_patient_anns_revisions.rds") %>%
18 | dplyr::rename("visium_sample_id" = sample_id)
19 |
20 | deconv_res <- tibble("slide_path" = slide_files_full,
21 | "visium_sample_id" = slide_ids) %>%
22 | dplyr::mutate(deconv_mats = map(slide_path, ~ readRDS(.x) %>%
23 | as.data.frame() %>%
24 | rownames_to_column("spot_id") %>%
25 | pivot_longer(-spot_id,
26 | names_to = "cell_type",
27 | values_to = "c2l_value"))) %>%
28 | dplyr::select(-slide_path) %>%
29 | unnest()
30 |
31 | # Then we filter all location scores that represent less than 1 cell per spot given our priors
32 | # prior from nuclei quantification
33 |
34 | deconv_res <- deconv_res %>%
35 | group_by(visium_sample_id, spot_id) %>%
36 | mutate(n_cells_spot = sum(c2l_value)) %>%
37 | mutate(c2l_value_prop = c2l_value / n_cells_spot) %>%
38 | dplyr::filter(n_cells_spot > 0) %>%
39 | ungroup()
40 |
41 | # Here we add the patient information
42 |
43 | deconv_res <- left_join(deconv_res, visium_anns)
44 |
45 | spatial_props <- deconv_res %>%
46 | group_by(patient_id, cell_type) %>%
47 | summarize(sp_n_cells = sum(c2l_value)) %>%
48 | ungroup() %>%
49 | group_by(patient_id) %>%
50 | mutate(sp_prop_cells = sp_n_cells/sum(sp_n_cells))
51 |
52 | write.table(spatial_props, file = "./results/compositions/spatial_compositions.txt", col.names = T, row.names = F, quote = F, sep = "\t")
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
--------------------------------------------------------------------------------
/st_snRNAseq/10_cellstates/.Rapp.history:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/KramannLab/visium_heart/03f4cf05328d7ff76ddadc18fcd0cfdbef360909/st_snRNAseq/10_cellstates/.Rapp.history
--------------------------------------------------------------------------------
/st_snRNAseq/10_cellstates/Myeloid/run_misty_Myeloid_cts.R:
--------------------------------------------------------------------------------
1 | # Copyright (c) [2021] [Ricardo O. Ramirez Flores]
2 | # roramirezf@uni-heidelberg.de
3 |
4 | #' Test a simplified version of the spatial analysis of interacting cells of interest
5 |
6 | library(tidyverse)
7 | library(Seurat)
8 | library(mistyR)
9 | source("./analysis/utils/misty_utilities.R")
10 | source("./analysis/utils/misty_pipeline.R")
11 |
12 | future::plan(future::multisession)
13 |
14 | # Main ------------------------------------------------------------------------
15 | # Getting sample annotations --------------------------------------------------
16 | sample_dict <- readRDS("./markers/visium_patient_anns_revisions.rds")
17 | slide_files_folder <- "./processed_visium/objects/"
18 | slide_files <- list.files(slide_files_folder)
19 | slide_ids <- gsub("[.]rds", "", slide_files)
20 |
21 | # Targets
22 | target_list <- c("Myeloid-DCs-FLT3-ITGAX", "Myeloid-LYVE-FOLR-Macrophages",
23 | "Myeloid-LYVE-PLTP-Macrophages", "Myeloid-Monocyte-CCL18",
24 | "Myeloid-Monocyte-SPP1")
25 |
26 | # Fibrosis ROI -----------------------------------------------
27 |
28 | run_state_ppline_ct(ROI_ct = "Myeloid",
29 | ROI_prop = 0.1,
30 | mask_by_prop = F,
31 | mask_threshold = 0.1,
32 | folder_label = "Myeloid_ct",
33 | targets = target_list,
34 | target_assay = "cell_states")
35 |
36 | misty_out_folder <- "./results/state_structure/Myeloid_ct/"
37 | performance_all_misty(misty_out_folder, r2_filter = 25)
38 |
39 | # run_state_ppline_ct(ROI_ct = "Myeloid",
40 | # ROI_prop = 0.1,
41 | # mask_by_prop = F,
42 | # mask_threshold = 0.1,
43 | # folder_label = "Myeloid_ct_pos",
44 | # targets = target_list,
45 | # target_assay = "cell_states_pos")
46 | #
47 | # misty_out_folder <- "./results/state_structure/Myeloid_ct_pos/"
48 | # performance_all_misty(misty_out_folder, r2_filter = 0.1)
49 |
50 |
51 |
52 |
--------------------------------------------------------------------------------
/st_snRNAseq/10_cellstates/fetch_annotations.R:
--------------------------------------------------------------------------------
1 | # Copyright (c) [2020] [Ricardo O. Ramirez Flores]
2 | # roramirezf@uni-heidelberg.de
3 |
4 | #' Get joint annotation of cell-states
5 |
6 | library(Seurat)
7 | library(tidyverse)
8 |
9 | folder = "./atac_rna_states"
10 | all_objs <- list.files(folder, recursive = T,full.names = T)
11 |
12 | all_annotations <- map(all_objs, function(fname) {
13 |
14 | cell_obj <- readRDS(fname)
15 |
16 | if("tech" %in% colnames(cell_obj@meta.data)) {
17 |
18 | cell_obj@meta.data %>%
19 | as.data.frame() %>%
20 | rownames_to_column("raw_id") %>%
21 | dplyr::filter(tech == "RNA") %>%
22 | dplyr::select(raw_id, orig.ident,cell_type, annotation)
23 |
24 | } else {
25 |
26 | cell_obj@meta.data %>%
27 | as.data.frame() %>%
28 | rownames_to_column("raw_id") %>%
29 | dplyr::select(raw_id, orig.ident,cell_type, annotation)
30 |
31 | }
32 |
33 | })
34 |
35 | saveRDS(all_annotations, "./processed_snrnaseq/cell_states/cellstate_annotation_list.rds")
36 |
37 |
38 |
39 |
40 |
41 |
--------------------------------------------------------------------------------
/st_snRNAseq/10_cellstates/get_integrated_annobj.R:
--------------------------------------------------------------------------------
1 | # Copyright (c) [2020] [Ricardo O. Ramirez Flores]
2 | # roramirezf@uni-heidelberg.de
3 |
4 | #' Get joint annotation of cell-states
5 |
6 | library(Seurat)
7 | library(tidyverse)
8 |
9 | annotation_list <- readRDS("./processed_snrnaseq/cell_states/cellstate_annotation_list.rds")
10 |
11 | all_annotations <- enframe(annotation_list) %>%
12 | unnest() %>%
13 | dplyr::select(-name)
14 |
15 | sc_data <- readRDS("./processed_snrnaseq/integration/integrated_rnasamples_ann.rds")
16 |
17 | cell_state_annotation <- sc_data@meta.data %>%
18 | as.data.frame() %>%
19 | rownames_to_column("raw_id") %>%
20 | left_join(all_annotations) %>%
21 | dplyr::filter(!is.na(annotation))
22 |
23 | sc_data <- sc_data[, cell_state_annotation$raw_id]
24 |
25 | sc_data$annotation <- cell_state_annotation$annotation
26 |
27 | saveRDS(sc_data, file = "./processed_snrnaseq/cell_states/integrated_rnasamples_ann_wstates.rds")
--------------------------------------------------------------------------------
/st_snRNAseq/11_compareATACRNA/.Rapp.history:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/KramannLab/visium_heart/03f4cf05328d7ff76ddadc18fcd0cfdbef360909/st_snRNAseq/11_compareATACRNA/.Rapp.history
--------------------------------------------------------------------------------
/st_snRNAseq/11_compareATACRNA/get_consensus_grn.R:
--------------------------------------------------------------------------------
1 | # Copyright (c) [2021] [Ricardo O. Ramirez Flores]
2 | # roramirezf@uni-heidelberg.de
3 |
4 | #' Here we build a tissue consensus network
5 | #'
6 |
7 | grns <- list.files("./reg_nets/processed/")
8 | grns <- set_names(paste0("./reg_nets/processed/", grns),
9 | gsub("[.]txt","",grns))
10 |
11 | all_nets <- map(grns, read_table2, col_names = T) %>%
12 | enframe() %>%
13 | unnest()
14 |
15 | norm_factor <- unique(all_nets$name) %>%
16 | length()
17 |
18 | all_nets <- all_nets %>%
19 | mutate() %>%
20 | dplyr::select(-c("name", "n_reads", "max_reads")) %>%
21 | group_by(source, target) %>%
22 | dplyr::summarize(likelihood = sum(likelihood)) %>%
23 | dplyr::mutate(likelihood = likelihood/norm_factor) %>%
24 | dplyr::mutate(mor = 1)
25 |
26 | saveRDS(all_nets, file = "./reg_nets/tissue_consensus_net.rds")
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
--------------------------------------------------------------------------------
/st_snRNAseq/11_compareATACRNA/get_grns.R:
--------------------------------------------------------------------------------
1 | # Copyright (c) [2021] [Ricardo O. Ramirez Flores]
2 | # roramirezf@uni-heidelberg.de
3 |
4 | #' Here we build networks and evaluate them before comparing them with HINT results
5 | #' All networks have the same number of TFs but not interactions
6 |
7 | grns <- list.files("./reg_nets/raw/")
8 |
9 | grns <- set_names(paste0("./reg_nets/raw/", grns),
10 | gsub("[.]txt","",grns))
11 |
12 | all_nets <- map(grns, read_table2, col_names = F) %>%
13 | enframe() %>%
14 | unnest()
15 |
16 | colnames(all_nets) <- c("cell_type", "source",
17 | "target", "n_reads")
18 |
19 | # We will weight them by the max number of reads around the binding site
20 |
21 | w_grns <- all_nets %>%
22 | group_by(cell_type, source) %>%
23 | mutate(max_reads = max(n_reads)) %>%
24 | mutate(likelihood = n_reads/max_reads) %>%
25 | dplyr::filter(likelihood > 0.3) %>%
26 | dplyr::mutate(mor = 1) %>%
27 | ungroup() %>%
28 | group_by(cell_type) %>%
29 | nest() %>%
30 | mutate(out_file = paste0("./reg_nets/processed/", cell_type,".txt"))
31 |
32 | walk2(w_grns$data, w_grns$out_file, function(dat, f){
33 | print(f)
34 | write.table(dat, file = f,col.names = T, row.names = F, sep = "\t", quote = F)
35 | })
36 |
37 |
--------------------------------------------------------------------------------
/st_snRNAseq/14_cellcomms/plt_CM.R:
--------------------------------------------------------------------------------
1 | # Copyright (c) [2021] [Ricardo O. Ramirez Flores]
2 | # roramirezf@uni-heidelberg.de
3 |
4 | #' In this script we process results from the
5 | #' CM -> state interactions
6 | #'
7 | source("./analysis/utils/liana_utils.R")
8 | library(liana)
9 |
10 | # Get results from myofibroblast and myeloid
11 |
12 | liana_res <- readRDS("./results/cell_comms/CM/liana_CM.rds")
13 |
14 | cpdb <- liana_res$cellphonedb %>%
15 | dplyr::select(source, target, ligand, receptor, lr.mean)
16 |
17 | liana_res <- liana_res%>%
18 | liana_aggregate() %>%
19 | mutate(log10pvalue = -log10(cellphonedb.pvalue + 0.000001)) %>%
20 | dplyr::left_join(cpdb, by = c("source", "target", "ligand", "receptor"))
21 |
22 | # Get the top 10 ligands
23 | cm <- c("damaged_CM")
24 | cts <- c("Fib", "Adipo", "vSMCs", "Myeloid")
25 |
26 | liana_outs(source_groups = cts,
27 | target_groups = cm,
28 | top = 5,
29 | file_alias = paste0(cm, "_", "rec", "_"),
30 | max_interactions = 2,
31 | filter_marker_genes = T,
32 | out_dir = "./results/cell_comms/CM/")
33 |
34 | liana_outs(source_groups = cm,
35 | target_groups = cts,
36 | top = 5,
37 | file_alias = paste0(cm, "_", "snd", "_"),
38 | max_interactions = 2,
39 | filter_marker_genes = T,
40 | out_dir = "./results/cell_comms/CM/")
41 |
42 |
43 |
--------------------------------------------------------------------------------
/st_snRNAseq/14_cellcomms/plt_endo.R:
--------------------------------------------------------------------------------
1 | # Copyright (c) [2021] [Ricardo O. Ramirez Flores]
2 | # roramirezf@uni-heidelberg.de
3 |
4 | #' In this script we process results from the
5 | #' Endo -> cts interactions
6 | #'
7 | source("./analysis/utils/liana_utils.R")
8 | library(liana)
9 |
10 | # Get results from myofibroblast and myeloid
11 |
12 | liana_res <- readRDS("./results/cell_comms/Endo/liana_Endo.rds")
13 |
14 | cpdb <- liana_res$cellphonedb %>%
15 | dplyr::select(source, target, ligand, receptor, lr.mean)
16 |
17 | liana_res <- liana_res %>%
18 | liana_aggregate() %>%
19 | mutate(log10pvalue = -log10(cellphonedb.pvalue + 0.000001)) %>%
20 | dplyr::left_join(cpdb, by = c("source", "target", "ligand", "receptor"))
21 |
22 |
23 | # Get the top 10 ligands
24 | states <- c( "Arterial_Endo", "Lymphatic_Endo", "Capillary_Endo", "Venous_Endo", "Endocardial_Endo")
25 | cts <- c("Fib", "CM", "vSMCs", "PC")
26 |
27 | walk(states, function(state) {
28 |
29 | print(state)
30 |
31 | liana_outs(source_groups = cts,
32 | target_groups = state,
33 | top = 10,
34 | file_alias = paste0(state, "_", "rec", "_"),
35 | max_interactions = 2,
36 | filter_marker_genes = T,
37 | out_dir = "./results/cell_comms/Endo/")
38 |
39 | liana_outs(source_groups = state,
40 | target_groups = cts,
41 | top = 10,
42 | file_alias = paste0(state, "_", "snd", "_"),
43 | max_interactions = 2,
44 | filter_marker_genes = T,
45 | out_dir = "./results/cell_comms/Endo/")
46 |
47 | })
48 |
49 |
50 |
51 |
--------------------------------------------------------------------------------
/st_snRNAseq/15_imaging/quantify_cmstates.R:
--------------------------------------------------------------------------------
1 | # Copyright (c) [2022] [Ricardo O. Ramirez Flores]
2 | # roramirezf@uni-heidelberg.de
3 |
4 | #' Plotting imaging results
5 |
6 | library(tidyverse)
7 | library(ggpubr)
8 |
9 | my_comparisons <- list( c("control", "MI"))
10 |
11 | NPPB <- read_table2("./results/imaging/kuppe_rnascope.cm_states.count_table.2022_02_28.tsv") %>%
12 | ggplot(aes(x = group, y = NPPB_normalized)) +
13 | geom_boxplot() +
14 | stat_compare_means(comparisons = my_comparisons) +
15 | theme_minimal() +
16 | theme(axis.text.x = element_text(angle = 90, hjust = 1, vjust = 0.5),
17 | axis.text = element_text(size = 12),
18 | panel.border = element_rect(colour = "black",
19 | fill=NA, size=0.5))
20 |
21 | ANKRD1 <- read_table2("./results/imaging/kuppe_rnascope.cm_states.count_table.2022_02_28.tsv") %>%
22 | ggplot(aes(x = group, y = ANKRD1_normalized)) +
23 | geom_boxplot() +
24 | stat_compare_means(comparisons = my_comparisons) +
25 | theme_minimal() +
26 | theme(axis.text.x = element_text(angle = 90, hjust = 1, vjust = 0.5),
27 | axis.text = element_text(size = 12),
28 | panel.border = element_rect(colour = "black",
29 | fill=NA, size=0.5))
30 |
31 |
32 | pdf("./results/imaging/CM_NPPB_pos.pdf", height = 4, width = 2.5)
33 |
34 | plot(NPPB)
35 |
36 | dev.off()
37 |
38 |
39 | pdf("./results/imaging/CM_ANKRD1_pos.pdf", height = 4, width = 2.5)
40 |
41 | plot(ANKRD1)
42 |
43 | dev.off()
44 |
45 |
--------------------------------------------------------------------------------
/st_snRNAseq/15_imaging/quantify_myeloid.R:
--------------------------------------------------------------------------------
1 | # Copyright (c) [2022] [Ricardo O. Ramirez Flores]
2 | # roramirezf@uni-heidelberg.de
3 |
4 | #' Generate plots of myeloid quantification
5 | #'
6 |
7 | library(tidyverse)
8 |
9 | # SPP1 is more abundant in IZ samples
10 |
11 | spp1_postn <- read_table2("./results/spp1_quant_manual/kuppe_rnascope.fibroblast_myeloid.cell_marker_counts.2022_03_09.tsv")
12 |
13 | my_comps <- list(c("control", "FZ"), c("control", "IZ"), c("FZ", "IZ"))
14 |
15 | spp1_postn <- ggplot(spp1_postn, aes(x = sample_group, y = SPP1_CD163_norm_to_CD163, color = sample_group)) +
16 | geom_boxplot() +
17 | geom_point() +
18 | ylab("SPP1+ macrophage proportion") +
19 | ggpubr::stat_compare_means(comparisons = my_comps) +
20 | theme_minimal() +
21 | theme(axis.text.x = element_text(angle = 90,
22 | hjust = 1,
23 | vjust = 0.5),
24 | axis.text = element_text(size = 12),
25 | panel.border = element_rect(colour = "black", fill=NA, size=1))
26 |
27 |
28 | pdf("./results/imaging/SPP1_quant_pos.pdf", width = 3,height = 4)
29 |
30 | plot(spp1_postn)
31 |
32 | dev.off()
33 |
34 | # There are other cells besides SPP1
35 |
36 | spp1_postn <- read_csv("./results/spp1_quant_manual/Mappe1_1.csv")
37 |
38 | spp1_postn <- spp1_postn %>%
39 | mutate(sample = paste0("sample", seq(1, nrow(spp1_postn)))) %>%
40 | pivot_longer(-sample)
41 |
42 |
43 | my_comps <- list(c("ccr2", "spp1"), c("ccr2", "trem2"), c("spp1", "trem2"))
44 |
45 | trem2_plt <- ggplot(spp1_postn, aes(x = name, y = value)) +
46 | geom_boxplot() +
47 | geom_point(aes()) +
48 | ylab("Myeloid cell-type proportion") +
49 | theme_minimal() +
50 | theme(axis.text.x = element_text(angle = 90,
51 | hjust = 1,
52 | vjust = 0.5),
53 | axis.text = element_text(size = 12),
54 | panel.border = element_rect(colour = "black", fill=NA, size=1)) +
55 | ggpubr::stat_compare_means(paired = T,method = "wilcox.test", comparisons = my_comps)
56 |
57 |
58 | pdf("./results/imaging/TREM2_quant_pos.pdf", width = 3,height = 4)
59 |
60 | plot(trem2_plt)
61 |
62 | dev.off()
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
--------------------------------------------------------------------------------
/st_snRNAseq/jobs/add_niches.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | cd /Users/ricardoramirez/Dropbox/PhD/Research/mi_atlas;
4 |
5 | Rscript ./analysis/utils/add_niche_info.R \
6 | --visium_folder "./processed_visium/objects/" \
7 | --pseudobulk_file "./processed_visium/integration/ps_integrated_slides_niches.rds";
8 |
--------------------------------------------------------------------------------
/st_snRNAseq/jobs/c2l_deconv_pt1.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | #SBATCH --job-name=nbsingularity
3 | #SBATCH -t 2000:00
4 | #SBATCH --mail-user=roramirezf@uni-heidelberg.de
5 | #SBATCH --mail-type=END
6 | #SBATCH --output /net/data.isilon/ag-saez/bq_rramirez/MI_deconvolution/jobs/c2l_deconv_pt1.out
7 |
8 | module load system/singularity;
9 |
10 | cd /net/data.isilon/ag-saez/bq_rramirez/MI_deconvolution/;
11 |
12 | for i in {AKK006_157771,Visium_1_CK279,Visium_2_CK280,Visium_3_CK281,Visium_4_CK282,Visium_5_CK283,Visium_6_CK284}
13 | do
14 | singularity exec --nv -B \
15 | /net/data.isilon/ag-saez/bq_rramirez/MI_deconvolution/ \
16 | /net/data.isilon/ag-saez/bq_rramirez/MI_deconvolution/cell2location-v0.05-alpha.sif \
17 | /bin/bash -c \
18 | "echo $i;
19 | python ./scripts/run_c2l.py $i";
20 | done
21 |
--------------------------------------------------------------------------------
/st_snRNAseq/jobs/c2l_deconv_pt2.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | #SBATCH --job-name=nbsingularity
3 | #SBATCH -t 2000:00
4 | #SBATCH --mail-user=roramirezf@uni-heidelberg.de
5 | #SBATCH --mail-type=END
6 | #SBATCH --output /net/data.isilon/ag-saez/bq_rramirez/MI_deconvolution/jobs/c2l_deconv_pt2.out
7 |
8 | module load system/singularity;
9 |
10 | cd /net/data.isilon/ag-saez/bq_rramirez/MI_deconvolution/;
11 |
12 | for i in {AKK001_157785,AKK002_157779,AKK002_157781,AKK002_157782,AKK003_157775,AKK003_157777,AKK004_157772}
13 | do
14 | singularity exec --nv -B \
15 | /net/data.isilon/ag-saez/bq_rramirez/MI_deconvolution/ \
16 | /net/data.isilon/ag-saez/bq_rramirez/MI_deconvolution/cell2location-v0.05-alpha.sif \
17 | /bin/bash -c \
18 | "echo $i;
19 | python ./scripts/run_c2l.py $i";
20 | done
21 |
--------------------------------------------------------------------------------
/st_snRNAseq/jobs/c2l_deconv_pt3.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | #SBATCH --job-name=nbsingularity
3 | #SBATCH -t 2000:00
4 | #SBATCH --mail-user=roramirezf@uni-heidelberg.de
5 | #SBATCH --mail-type=END
6 | #SBATCH --output /net/data.isilon/ag-saez/bq_rramirez/MI_deconvolution/jobs/c2l_deconv_pt3.out
7 |
8 | module load system/singularity;
9 |
10 | cd /net/data.isilon/ag-saez/bq_rramirez/MI_deconvolution/;
11 |
12 | for i in {Visium_7_CK285,Visium_8_CK286,Visium_9_CK287,Visium_10_CK288,Visium_11_CK289,Visium_12_CK290,Visium_13_CK291}
13 | do
14 | singularity exec --nv -B \
15 | /net/data.isilon/ag-saez/bq_rramirez/MI_deconvolution/ \
16 | /net/data.isilon/ag-saez/bq_rramirez/MI_deconvolution/cell2location-v0.05-alpha.sif \
17 | /bin/bash -c \
18 | "echo $i;
19 | python ./scripts/run_c2l.py $i";
20 | done
21 |
--------------------------------------------------------------------------------
/st_snRNAseq/jobs/c2l_deconv_pt4.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | #SBATCH --job-name=nbsingularity
3 | #SBATCH -t 2000:00
4 | #SBATCH --mail-user=roramirezf@uni-heidelberg.de
5 | #SBATCH --mail-type=END
6 | #SBATCH --output /net/data.isilon/ag-saez/bq_rramirez/MI_deconvolution/jobs/c2l_deconv_pt4.out
7 |
8 | module load system/singularity;
9 |
10 | cd /net/data.isilon/ag-saez/bq_rramirez/MI_deconvolution/;
11 |
12 | for i in {Visium_14_CK292,Visium_15_CK293,Visium_16_CK294,Visium_17_CK295,Visium_18_CK296,Visium_19_CK297,Visium_20_CK298}
13 | do
14 | singularity exec --nv -B \
15 | /net/data.isilon/ag-saez/bq_rramirez/MI_deconvolution/ \
16 | /net/data.isilon/ag-saez/bq_rramirez/MI_deconvolution/cell2location-v0.05-alpha.sif \
17 | /bin/bash -c \
18 | "echo $i;
19 | python ./scripts/run_c2l.py $i";
20 | done
21 |
--------------------------------------------------------------------------------
/st_snRNAseq/jobs/c2l_nb_states_gpu_singularity.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | #SBATCH --job-name=nbsingularity
4 | #SBATCH -t 1000:00
5 | #SBATCH --mail-user=roramirezf@uni-heidelberg.de
6 | #SBATCH --mail-type=END
7 | #SBATCH --output /net/data.isilon/ag-saez/bq_rramirez/MI_deconvolution/jobs/c2l_nb_states_gpu_singularity.out
8 |
9 | module load system/singularity;
10 |
11 | cd /net/data.isilon/ag-saez/bq_rramirez/MI_deconvolution/;
12 |
13 | singularity exec --nv -B \
14 | /net/data.isilon/ag-saez/bq_rramirez/MI_deconvolution/ \
15 | /net/data.isilon/ag-saez/bq_rramirez/MI_deconvolution/cell2location-v0.05-alpha.sif \
16 | /bin/bash -c \
17 | "python ./scripts/nb_estimates_states_singularity.py";
18 |
--------------------------------------------------------------------------------
/st_snRNAseq/jobs/estimate_klatlas_markers.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | #PBS -l nodes=1:ppn=8
3 | #PBS -l walltime=08:00:00
4 | #PBS -l mem=64gb
5 | #PBS -S /bin/bash
6 | #PBS -N visium_mrkr_estimation
7 | #PBS -o /beegfs/work/hd_wh241/MI_revisions/analysis/jobs/estimate_kl_miatlas_markers.out
8 | #PBS -e /beegfs/work/hd_wh241/MI_revisions/analysis/jobs/estimate_kl_miatlas_markers.err
9 | #PBS -q short
10 | #PBS -m bea
11 | #PBS -M roramirezf@uni-heidelberg.de
12 |
13 | source ~/.bashrc;
14 | conda activate sc_analysis;
15 | cd /beegfs/work/hd_wh241/MI_revisions;
16 |
17 | $CONDA_PREFIX/bin/Rscript ./analysis/3_functional_characterization/estimate_dea.R \
18 | --data_path "/beegfs/work/hd_wh241/MI_revisions/kl_miatlas/kl_miatlas_integrated_data.rds" \
19 | --out_df "/beegfs/work/hd_wh241/MI_revisions/kl_miatlas/kl_miatlas_mrkrs.rds" \
20 | --group_class "opt_clust_integrated" \
21 | --test_assays "RNA" \
22 | --lfc "0.5" \
23 | --only_pos "yes";
--------------------------------------------------------------------------------
/st_snRNAseq/jobs/estimate_snrseqclust_markers.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | #PBS -l nodes=1:ppn=8
3 | #PBS -l walltime=18:00:00
4 | #PBS -l mem=150gb
5 | #PBS -S /bin/bash
6 | #PBS -N snrnaseq_mrkr_estimation
7 | #PBS -o /beegfs/work/hd_wh241/MI_revisions/analysis/jobs/estimate_snrseqclust_markers.out
8 | #PBS -e /beegfs/work/hd_wh241/MI_revisions/analysis/jobs/estimate_snrseqclust_markers.err
9 | #PBS -q smp
10 | #PBS -m bea
11 | #PBS -M roramirezf@uni-heidelberg.de
12 |
13 | source ~/.bashrc;
14 | conda activate sc_analysis;
15 | cd /beegfs/work/hd_wh241/MI_revisions;
16 |
17 | $CONDA_PREFIX/bin/Rscript ./analysis/3_functional_characterization/estimate_dea.R \
18 | --data_path "/beegfs/work/hd_wh241/MI_revisions/processed_snrnaseq/integration/integrated_rnasamples.rds" \
19 | --out_df "/beegfs/work/hd_wh241/MI_revisions/processed_snrnaseq/integration/integrated_rnasamples_mrkrs.rds" \
20 | --group_class "opt_clust_integrated" \
21 | --test_assays "RNA" \
22 | --lfc "0.5" \
23 | --only_pos "yes";
--------------------------------------------------------------------------------
/st_snRNAseq/jobs/estimate_spatial_tfs.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | #PBS -l nodes=1:ppn=4
3 | #PBS -l walltime=24:00:00
4 | #PBS -l mem=130gb
5 | #PBS -S /bin/bash
6 | #PBS -N spatial_tfs
7 | #PBS -o /beegfs/work/hd_wh241/MI_revisions/analysis/jobs/estimate_spatial_tfs.out
8 | #PBS -e /beegfs/work/hd_wh241/MI_revisions/analysis/jobs/estimate_spatial_tfs.err
9 | #PBS -q smp
10 | #PBS -m bea
11 | #PBS -M roramirezf@uni-heidelberg.de
12 |
13 | source ~/.bashrc;
14 | conda activate sc_analysis;
15 | cd /beegfs/work/hd_wh241/MI_revisions;
16 |
17 | $CONDA_PREFIX/bin/Rscript ./analysis/1.1_spatial_QC_reading/estimate_tfacts.R;
--------------------------------------------------------------------------------
/st_snRNAseq/jobs/estimate_visiumclust_markers.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | #PBS -l nodes=1:ppn=16
3 | #PBS -l walltime=24:00:00
4 | #PBS -l mem=150gb
5 | #PBS -S /bin/bash
6 | #PBS -N visium_mrkr_estimation
7 | #PBS -o /beegfs/work/hd_wh241/MI_revisions/analysis/jobs/estimate_visiumclust_markers.out
8 | #PBS -e /beegfs/work/hd_wh241/MI_revisions/analysis/jobs/estimate_visiumclust_markers.err
9 | #PBS -q smp
10 | #PBS -m bea
11 | #PBS -M roramirezf@uni-heidelberg.de
12 |
13 | source ~/.bashrc;
14 | conda activate sc_analysis;
15 | cd /beegfs/work/hd_wh241/MI_revisions;
16 |
17 | $CONDA_PREFIX/bin/Rscript ./analysis/3_functional_characterization/estimate_dea.R \
18 | --data_path "/beegfs/work/hd_wh241/MI_revisions/processed_visium/integration/integrated_slides.rds" \
19 | --out_df "/beegfs/work/hd_wh241/MI_revisions/processed_visium/integration/integrated_slides_mrkrs.rds" \
20 | --group_class "opt_clust_integrated" \
21 | --test_assays "Spatial" \
22 | --lfc "0.5" \
23 | --only_pos "yes";
--------------------------------------------------------------------------------
/st_snRNAseq/jobs/estimate_visiumclust_markers_ILR.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | #PBS -l nodes=1:ppn=16
3 | #PBS -l walltime=30:00:00
4 | #PBS -l mem=150gb
5 | #PBS -S /bin/bash
6 | #PBS -N visium_mrkr_estimation
7 | #PBS -o /beegfs/work/hd_wh241/MI_revisions/analysis/jobs/estimate_visiumclust_markers_ILR.out
8 | #PBS -e /beegfs/work/hd_wh241/MI_revisions/analysis/jobs/estimate_visiumclust_markers_ILR.err
9 | #PBS -q smp
10 | #PBS -m bea
11 | #PBS -M roramirezf@uni-heidelberg.de
12 |
13 | source ~/.bashrc;
14 | conda activate sc_analysis;
15 | cd /beegfs/work/hd_wh241/MI_revisions;
16 |
17 | $CONDA_PREFIX/bin/Rscript ./analysis/2_snuc_integration_harmony/add_all_annotations_spatial.R;
18 |
19 | $CONDA_PREFIX/bin/Rscript ./analysis/3_functional_characterization/estimate_dea.R \
20 | --data_path "/beegfs/work/hd_wh241/MI_revisions/processed_visium/integration/integrated_slides_ann.rds" \
21 | --out_df "/beegfs/work/hd_wh241/MI_revisions/processed_visium/integration/integrated_slides_mrkrs_ILR.rds" \
22 | --group_class "niche_ILR" \
23 | --test_assays "Spatial" \
24 | --lfc "0.5" \
25 | --only_pos "yes";
--------------------------------------------------------------------------------
/st_snRNAseq/jobs/estimate_visiumclust_markers_molecular.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | #PBS -l nodes=1:ppn=16
3 | #PBS -l walltime=30:00:00
4 | #PBS -l mem=150gb
5 | #PBS -S /bin/bash
6 | #PBS -N visium_mrkr_estimation
7 | #PBS -o /beegfs/work/hd_wh241/MI_revisions/analysis/jobs/estimate_visiumclust_markers_molecular.out
8 | #PBS -e /beegfs/work/hd_wh241/MI_revisions/analysis/jobs/estimate_visiumclust_markers_molecular.err
9 | #PBS -q smp
10 | #PBS -m bea
11 | #PBS -M roramirezf@uni-heidelberg.de
12 |
13 | source ~/.bashrc;
14 | conda activate sc_analysis;
15 | cd /beegfs/work/hd_wh241/MI_revisions;
16 |
17 | $CONDA_PREFIX/bin/Rscript ./analysis/3_functional_characterization/estimate_dea.R \
18 | --data_path "/beegfs/work/hd_wh241/MI_revisions/processed_visium/integration/integrated_slides.rds" \
19 | --out_df "/beegfs/work/hd_wh241/MI_revisions/processed_visium/integration/integrated_slides_mrkrs_molecular.rds" \
20 | --group_class "Spatial_snn_res.0.2" \
21 | --test_assays "Spatial" \
22 | --lfc "0.3" \
23 | --only_pos "yes";
--------------------------------------------------------------------------------
/st_snRNAseq/jobs/fetch_state_annotations.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | #PBS -l nodes=1:ppn=16
3 | #PBS -l walltime=5:00:00
4 | #PBS -l mem=150gb
5 | #PBS -S /bin/bash
6 | #PBS -N visium_mrkr_estimation
7 | #PBS -o /beegfs/work/hd_wh241/MI_revisions/analysis/jobs/fetch_state_annotations.out
8 | #PBS -e /beegfs/work/hd_wh241/MI_revisions/analysis/jobs/fetch_state_annotations.err
9 | #PBS -q smp
10 | #PBS -m bea
11 | #PBS -M roramirezf@uni-heidelberg.de
12 |
13 | source ~/.bashrc;
14 | conda activate sc_analysis;
15 | cd /beegfs/work/hd_wh241/MI_revisions;
16 |
17 | $CONDA_PREFIX/bin/Rscript ./analysis/10_cellstates/fetch_annotations.R;
--------------------------------------------------------------------------------
/st_snRNAseq/jobs/generate_ann_snrnaseq_integrated.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | #PBS -l nodes=1:ppn=8
3 | #PBS -l walltime=08:00:00
4 | #PBS -l mem=200gb
5 | #PBS -S /bin/bash
6 | #PBS -N annotate_obj
7 | #PBS -o /beegfs/work/hd_wh241/MI_revisions/analysis/jobs/generate_ann_snrnaseq_integrated.out
8 | #PBS -e /beegfs/work/hd_wh241/MI_revisions/analysis/jobs/generate_ann_snrnaseq_integrated.err
9 | #PBS -q smp
10 | #PBS -m bea
11 | #PBS -M roramirezf@uni-heidelberg.de
12 |
13 | source ~/.bashrc;
14 | conda activate sc_analysis;
15 | cd /beegfs/work/hd_wh241/MI_revisions;
16 |
17 | $CONDA_PREFIX/bin/Rscript ./analysis/2_snuc_integration_harmony/annotate_object.R \
18 | --data_path "/beegfs/work/hd_wh241/MI_revisions/processed_snrnaseq/integration/integrated_rnasamples.rds" \
19 | --dictionary_path "/beegfs/work/hd_wh241/MI_revisions/markers/snrna_seq_cluster_annotations.txt" \
20 | --object_id "opt_clust_integrated" \
21 | --dictionary_id "opt_clust_integrated" \
22 | --new_variable "cell_type" \
23 | --out_path "/beegfs/work/hd_wh241/MI_revisions/processed_snrnaseq/integration/integrated_rnasamples_ann.rds";
24 |
25 | $CONDA_PREFIX/bin/Rscript ./analysis/1_snuc_QC_doublets_majorannotation/plot_knownmarkers.R \
26 | --used_assay "RNA" \
27 | --downsampling \
28 | --id_label "cell_type" \
29 | --path "/beegfs/work/hd_wh241/MI_revisions/processed_snrnaseq/integration/integrated_rnasamples_ann.rds" \
30 | --out_fig_path "/beegfs/work/hd_wh241/MI_revisions/processed_snrnaseq/integration/";
31 |
32 | $CONDA_PREFIX/bin/Rscript ./analysis/2_snuc_integration_harmony/process_ann_object.R \
33 | --data_path "/beegfs/work/hd_wh241/MI_revisions/processed_snrnaseq/integration/integrated_rnasamples_ann.rds" \
34 | --out_path "/beegfs/work/hd_wh241/MI_revisions/processed_snrnaseq/integration/integrated_rnasamples_ann.rds" \
35 | --out_fig_file "/beegfs/work/hd_wh241/MI_revisions/processed_snrnaseq/integration/integrated_rnasamples_ann_umap.pdf";
--------------------------------------------------------------------------------
/st_snRNAseq/jobs/generate_ann_snrnaseq_integrated_v2.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | #PBS -l nodes=1:ppn=8
3 | #PBS -l walltime=05:00:00
4 | #PBS -l mem=200gb
5 | #PBS -S /bin/bash
6 | #PBS -N annotate_obj
7 | #PBS -o /beegfs/work/hd_wh241/MI_revisions/analysis/jobs/generate_ann_snrnaseq_integrated_v2.out
8 | #PBS -e /beegfs/work/hd_wh241/MI_revisions/analysis/jobs/generate_ann_snrnaseq_integrated_v2.err
9 | #PBS -q smp
10 | #PBS -m bea
11 | #PBS -M roramirezf@uni-heidelberg.de
12 |
13 | source ~/.bashrc;
14 | conda activate sc_analysis;
15 | cd /beegfs/work/hd_wh241/MI_revisions;
16 |
17 | $CONDA_PREFIX/bin/Rscript ./analysis/2_snuc_integration_harmony/process_ann_object.R \
18 | --data_path "/beegfs/work/hd_wh241/MI_revisions/processed_snrnaseq/integration/integrated_rnasamples_ann.rds" \
19 | --out_path "/beegfs/work/hd_wh241/MI_revisions/processed_snrnaseq/integration/integrated_rnasamples_ann.rds" \
20 | --out_fig_file "/beegfs/work/hd_wh241/MI_revisions/processed_snrnaseq/integration/integrated_rnasamples_ann_umap.pdf";
--------------------------------------------------------------------------------
/st_snRNAseq/jobs/generate_ct_niches.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | #PBS -l nodes=1:ppn=8
3 | #PBS -l walltime=05:00:00
4 | #PBS -l mem=130gb
5 | #PBS -S /bin/bash
6 | #PBS -N annotate_obj
7 | #PBS -o /beegfs/work/hd_wh241/MI_revisions/analysis/jobs/generate_ct_niches.out
8 | #PBS -e /beegfs/work/hd_wh241/MI_revisions/analysis/jobs/generate_ct_niches.err
9 | #PBS -q smp
10 | #PBS -m bea
11 | #PBS -M roramirezf@uni-heidelberg.de
12 |
13 | source ~/.bashrc;
14 | conda activate sc_analysis;
15 | cd /beegfs/work/hd_wh241/MI_revisions;
16 |
17 | $CONDA_PREFIX/bin/Rscript ./analysis/5_colocalization/find_niches_ct.R
--------------------------------------------------------------------------------
/st_snRNAseq/jobs/get_cellcycle_scores.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | #PBS -l nodes=1:ppn=16
3 | #PBS -l walltime=30:00:00
4 | #PBS -l mem=150gb
5 | #PBS -S /bin/bash
6 | #PBS -N cellcycle
7 | #PBS -o /beegfs/work/hd_wh241/MI_revisions/analysis/jobs/get_cellcycle_scores.out
8 | #PBS -e /beegfs/work/hd_wh241/MI_revisions/analysis/jobs/get_cellcycle_scores.err
9 | #PBS -q smp
10 | #PBS -m bea
11 | #PBS -M roramirezf@uni-heidelberg.de
12 |
13 | source ~/.bashrc;
14 | conda activate sc_analysis;
15 | cd /beegfs/work/hd_wh241/MI_revisions;
16 |
17 | $CONDA_PREFIX/bin/Rscript ./analysis/2_snuc_integration_harmony/estimate_cellcycle.R;
18 |
--------------------------------------------------------------------------------
/st_snRNAseq/jobs/get_cellstates.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | #PBS -l nodes=1:ppn=8
3 | #PBS -l walltime=03:00:00
4 | #PBS -l mem=90gb
5 | #PBS -S /bin/bash
6 | #PBS -N cell_states
7 | #PBS -o /beegfs/work/hd_wh241/MI_revisions/analysis/jobs/get_cellstates.out
8 | #PBS -e /beegfs/work/hd_wh241/MI_revisions/analysis/jobs/get_cellstates.err
9 | #PBS -q short
10 | #PBS -m bea
11 | #PBS -M roramirezf@uni-heidelberg.de
12 |
13 | source ~/.bashrc;
14 | conda activate sc_analysis;
15 | cd /beegfs/work/hd_wh241/MI_revisions;
16 |
17 | for i in {cardiomyocyte,endothelial}
18 | do
19 | mkdir ./results/ct_data/$i;
20 |
21 | $CONDA_PREFIX/bin/Rscript ./analysis/2_snuc_integration_harmony/get_cell_states.R \
22 | --data_path "/beegfs/work/hd_wh241/MI_revisions/processed_snrnaseq/integration/integrated_rnasamples_ann.rds" \
23 | --out_path "/beegfs/work/hd_wh241/MI_revisions/results/ct_data/$i/$i_states.rds" \
24 | --out_fig_file "/beegfs/work/hd_wh241/MI_revisions/results/ct_data/$i/$i_states.pdf" \
25 | --cell_class $i \
26 | --class_label "cell_type" \
27 | --start_res 0.2;
28 |
29 | $CONDA_PREFIX/bin/Rscript ./analysis/3_functional_characterization/add_funcomics.R \
30 | --data_path "/beegfs/work/hd_wh241/MI_revisions/results/ct_data/$i/$i_states.rds" \
31 | --out_path "/beegfs/work/hd_wh241/MI_revisions/results/ct_data/$i/$i_states.rds" \
32 | --group_class "opt_state" \
33 | --gene_set_collection "not";
34 |
35 | $CONDA_PREFIX/bin/Rscript ./analysis/3_functional_characterization/estimate_dea.R \
36 | --data_path "/beegfs/work/hd_wh241/MI_revisions/results/ct_data/$i/$i_states.rds" \
37 | --out_df "/beegfs/work/hd_wh241/MI_revisions/results/ct_data/$i/$i_dea.rds" \
38 | --test_assays "RNA,progeny,dorothea" \
39 | --group_class "opt_state" \
40 | --lfc "0.20" \
41 | --only_pos "yes";
42 |
43 | $CONDA_PREFIX/bin/Rscript ./analysis/3_functional_characterization/plot_funcomics.R \
44 | --data_path "/beegfs/work/hd_wh241/MI_revisions/results/ct_data/$i/$i_states.rds" \
45 | --dea_data_path "/beegfs/work/hd_wh241/MI_revisions/results/ct_data/$i/$i_dea.rds" \
46 | --nfeats 10 \
47 | --ngenes_ORA 10 \
48 | --pvalue_ORA 0.15 \
49 | --pvalue 0.001 \
50 | --lfc 0.5 \
51 | --test_assays "RNA,progeny,dorothea" \
52 | --group_class "opt_state" \
53 | --out_path "/beegfs/work/hd_wh241/MI_revisions/results/ct_data/$i/$i";
54 | done
55 |
--------------------------------------------------------------------------------
/st_snRNAseq/jobs/get_cellstates_cardio.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | #PBS -l nodes=1:ppn=8
3 | #PBS -l walltime=08:00:00
4 | #PBS -l mem=150gb
5 | #PBS -S /bin/bash
6 | #PBS -N cell_states
7 | #PBS -o /beegfs/work/hd_wh241/MI_revisions/analysis/jobs/get_cellstates_CM.out
8 | #PBS -e /beegfs/work/hd_wh241/MI_revisions/analysis/jobs/get_cellstates_CM.err
9 | #PBS -q smp
10 | #PBS -m bea
11 | #PBS -M roramirezf@uni-heidelberg.de
12 |
13 | source ~/.bashrc;
14 | conda activate sc_analysis;
15 | cd /beegfs/work/hd_wh241/MI_revisions;
16 |
17 | mkdir ./results/ct_data/CM;
18 |
19 | $CONDA_PREFIX/bin/Rscript ./analysis/2_snuc_integration_harmony/get_cell_states.R \
20 | --data_path "/beegfs/work/hd_wh241/MI_revisions/processed_snrnaseq/integration/integrated_rnasamples_ann.rds" \
21 | --out_path "/beegfs/work/hd_wh241/MI_revisions/results/ct_data/CM/CM_states.rds" \
22 | --out_fig_file "/beegfs/work/hd_wh241/MI_revisions/results/ct_data/CM/CM_states.pdf" \
23 | --cell_class "CM" \
24 | --class_label "cell_type" \
25 | --start_res 0.5;
26 |
27 | $CONDA_PREFIX/bin/Rscript ./analysis/utils/h5ad_mirrors.R \
28 | --scell_data "/beegfs/work/hd_wh241/MI_revisions/results/ct_data/CM/CM_states.rds" \
29 | --out_file "/beegfs/work/hd_wh241/MI_revisions/results/ct_data/CM/CM_states.h5ad";
30 |
31 | $CONDA_PREFIX/bin/Rscript ./analysis/utils/sce_mirrors.R \
32 | --seurat_file "/beegfs/work/hd_wh241/MI_revisions/results/ct_data/CM/CM_states.rds" \
33 | --sce_folder "/beegfs/work/hd_wh241/MI_revisions/results/ct_data/CM/CM_states_sce" \
34 | --assay "RNA" \
35 | --reduction "umap";
36 |
37 | $CONDA_PREFIX/bin/Rscript ./analysis/6_atlas_comparison/get_pseudobulk_profiles.R \
38 | --path "/beegfs/work/hd_wh241/MI_revisions/results/ct_data/CM/CM_states.rds" \
39 | --vars "orig.ident,opt_state" \
40 | --collapsed "yes" \
41 | --out_path "/beegfs/work/hd_wh241/MI_revisions/results/ct_data/CM/ps_CM_states.rds" \
42 | --def_assay "RNA";
43 |
--------------------------------------------------------------------------------
/st_snRNAseq/jobs/get_cellstates_cardio_filt.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | #PBS -l nodes=1:ppn=8
3 | #PBS -l walltime=08:00:00
4 | #PBS -l mem=150gb
5 | #PBS -S /bin/bash
6 | #PBS -N cell_states
7 | #PBS -o /beegfs/work/hd_wh241/MI_revisions/analysis/jobs/get_cellstates_filt_CM.out
8 | #PBS -e /beegfs/work/hd_wh241/MI_revisions/analysis/jobs/get_cellstates_filt_CM.err
9 | #PBS -q smp
10 | #PBS -m bea
11 | #PBS -M roramirezf@uni-heidelberg.de
12 |
13 | source ~/.bashrc;
14 | conda activate sc_analysis;
15 | cd /beegfs/work/hd_wh241/MI_revisions;
16 |
17 | mkdir ./results/ct_data_filt/CM;
18 |
19 | $CONDA_PREFIX/bin/Rscript ./analysis/10_cellstates/get_filtered_states.R \
20 | --data_path "/beegfs/work/hd_wh241/MI_revisions/results/ct_data/CM/CM_states.rds" \
21 | --out_path "/beegfs/work/hd_wh241/MI_revisions/results/ct_data_filt/CM/CM_states.rds" \
22 | --out_fig_file "/beegfs/work/hd_wh241/MI_revisions/results/ct_data_filt/CM/CM_states.pdf" \
23 | --cell_class_excl "1,4,7" \
24 | --class_label "opt_state" \
25 | --start_res 0.3;
26 |
27 | $CONDA_PREFIX/bin/Rscript ./analysis/utils/h5ad_mirrors.R \
28 | --scell_data "/beegfs/work/hd_wh241/MI_revisions/results/ct_data_filt/CM/CM_states.rds" \
29 | --out_file "/beegfs/work/hd_wh241/MI_revisions/results/ct_data_filt/CM/CM_states.h5ad";
30 |
31 | $CONDA_PREFIX/bin/Rscript ./analysis/utils/sce_mirrors.R \
32 | --seurat_file "/beegfs/work/hd_wh241/MI_revisions/results/ct_data_filt/CM/CM_states.rds" \
33 | --sce_folder "/beegfs/work/hd_wh241/MI_revisions/results/ct_data_filt/CM/CM_states_sce" \
34 | --assay "RNA" \
35 | --reduction "umap";
36 |
37 | $CONDA_PREFIX/bin/Rscript ./analysis/6_atlas_comparison/get_pseudobulk_profiles.R \
38 | --path "/beegfs/work/hd_wh241/MI_revisions/results/ct_data_filt/CM/CM_states.rds" \
39 | --vars "orig.ident,opt_state" \
40 | --collapsed "yes" \
41 | --out_path "/beegfs/work/hd_wh241/MI_revisions/results/ct_data_filt/CM/ps_CM_states.rds" \
42 | --def_assay "RNA";
43 |
--------------------------------------------------------------------------------
/st_snRNAseq/jobs/get_cellstates_endo.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | #PBS -l nodes=1:ppn=8
3 | #PBS -l walltime=08:00:00
4 | #PBS -l mem=150gb
5 | #PBS -S /bin/bash
6 | #PBS -N cell_states
7 | #PBS -o /beegfs/work/hd_wh241/MI_revisions/analysis/jobs/get_cellstates_endo.out
8 | #PBS -e /beegfs/work/hd_wh241/MI_revisions/analysis/jobs/get_cellstates_endo.err
9 | #PBS -q smp
10 | #PBS -m bea
11 | #PBS -M roramirezf@uni-heidelberg.de
12 |
13 | source ~/.bashrc;
14 | conda activate sc_analysis;
15 | cd /beegfs/work/hd_wh241/MI_revisions;
16 |
17 | mkdir ./results/ct_data/Endo;
18 |
19 | $CONDA_PREFIX/bin/Rscript ./analysis/2_snuc_integration_harmony/get_cell_states.R \
20 | --data_path "/beegfs/work/hd_wh241/MI_revisions/processed_snrnaseq/integration/integrated_rnasamples_ann.rds" \
21 | --out_path "/beegfs/work/hd_wh241/MI_revisions/results/ct_data/Endo/Endo_states.rds" \
22 | --out_fig_file "/beegfs/work/hd_wh241/MI_revisions/results/ct_data/Endo/Endo_states.pdf" \
23 | --cell_class "Endo" \
24 | --class_label "cell_type" \
25 | --start_res 0.5;
26 |
27 | $CONDA_PREFIX/bin/Rscript ./analysis/utils/h5ad_mirrors.R \
28 | --scell_data "/beegfs/work/hd_wh241/MI_revisions/results/ct_data/Endo/Endo_states.rds" \
29 | --out_file "/beegfs/work/hd_wh241/MI_revisions/results/ct_data/Endo/Endo_states.h5ad";
30 |
31 | $CONDA_PREFIX/bin/Rscript ./analysis/utils/sce_mirrors.R \
32 | --seurat_file "/beegfs/work/hd_wh241/MI_revisions/results/ct_data/Endo/Endo_states.rds" \
33 | --sce_folder "/beegfs/work/hd_wh241/MI_revisions/results/ct_data/Endo/Endo_states_sce" \
34 | --assay "RNA" \
35 | --reduction "umap";
36 |
37 | $CONDA_PREFIX/bin/Rscript ./analysis/6_atlas_comparison/get_pseudobulk_profiles.R \
38 | --path "/beegfs/work/hd_wh241/MI_revisions/results/ct_data/Endo/Endo_states.rds" \
39 | --vars "orig.ident,opt_state" \
40 | --collapsed "yes" \
41 | --out_path "/beegfs/work/hd_wh241/MI_revisions/results/ct_data/Endo/ps_Endo_states.rds" \
42 | --def_assay "RNA";
43 |
--------------------------------------------------------------------------------
/st_snRNAseq/jobs/get_cellstates_endo_filt.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | #PBS -l nodes=1:ppn=8
3 | #PBS -l walltime=08:00:00
4 | #PBS -l mem=150gb
5 | #PBS -S /bin/bash
6 | #PBS -N cell_states
7 | #PBS -o /beegfs/work/hd_wh241/MI_revisions/analysis/jobs/get_cellstates_filt_Endo.out
8 | #PBS -e /beegfs/work/hd_wh241/MI_revisions/analysis/jobs/get_cellstates_filt_Endo.err
9 | #PBS -q smp
10 | #PBS -m bea
11 | #PBS -M roramirezf@uni-heidelberg.de
12 |
13 | source ~/.bashrc;
14 | conda activate sc_analysis;
15 | cd /beegfs/work/hd_wh241/MI_revisions;
16 |
17 | mkdir ./results/ct_data_filt/Endo;
18 |
19 | $CONDA_PREFIX/bin/Rscript ./analysis/10_cellstates/get_filtered_states.R \
20 | --data_path "/beegfs/work/hd_wh241/MI_revisions/results/ct_data/Endo/Endo_states.rds" \
21 | --out_path "/beegfs/work/hd_wh241/MI_revisions/results/ct_data_filt/Endo/Endo_states.rds" \
22 | --out_fig_file "/beegfs/work/hd_wh241/MI_revisions/results/ct_data_filt/Endo/Endo_states.pdf" \
23 | --cell_class_excl "1,6" \
24 | --class_label "opt_state" \
25 | --start_res 0.3;
26 |
27 | $CONDA_PREFIX/bin/Rscript ./analysis/utils/h5ad_mirrors.R \
28 | --scell_data "/beegfs/work/hd_wh241/MI_revisions/results/ct_data_filt/Endo/Endo_states.rds" \
29 | --out_file "/beegfs/work/hd_wh241/MI_revisions/results/ct_data_filt/Endo/Endo_states.h5ad";
30 |
31 | $CONDA_PREFIX/bin/Rscript ./analysis/utils/sce_mirrors.R \
32 | --seurat_file "/beegfs/work/hd_wh241/MI_revisions/results/ct_data_filt/Endo/Endo_states.rds" \
33 | --sce_folder "/beegfs/work/hd_wh241/MI_revisions/results/ct_data_filt/Endo/Endo_states_sce" \
34 | --assay "RNA" \
35 | --reduction "umap";
36 |
37 | $CONDA_PREFIX/bin/Rscript ./analysis/6_atlas_comparison/get_pseudobulk_profiles.R \
38 | --path "/beegfs/work/hd_wh241/MI_revisions/results/ct_data_filt/Endo/Endo_states.rds" \
39 | --vars "orig.ident,opt_state" \
40 | --collapsed "yes" \
41 | --out_path "/beegfs/work/hd_wh241/MI_revisions/results/ct_data_filt/Endo/ps_Endo_states.rds" \
42 | --def_assay "RNA";
43 |
--------------------------------------------------------------------------------
/st_snRNAseq/jobs/get_cellstates_fibro.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | #PBS -l nodes=1:ppn=8
3 | #PBS -l walltime=08:00:00
4 | #PBS -l mem=150gb
5 | #PBS -S /bin/bash
6 | #PBS -N cell_states
7 | #PBS -o /beegfs/work/hd_wh241/MI_revisions/analysis/jobs/get_cellstates_Fib.out
8 | #PBS -e /beegfs/work/hd_wh241/MI_revisions/analysis/jobs/get_cellstates_Fib.err
9 | #PBS -q smp
10 | #PBS -m bea
11 | #PBS -M roramirezf@uni-heidelberg.de
12 |
13 | source ~/.bashrc;
14 | conda activate sc_analysis;
15 | cd /beegfs/work/hd_wh241/MI_revisions;
16 |
17 | mkdir ./results/ct_data/Fib;
18 |
19 | $CONDA_PREFIX/bin/Rscript ./analysis/2_snuc_integration_harmony/get_cell_states.R \
20 | --data_path "/beegfs/work/hd_wh241/MI_revisions/processed_snrnaseq/integration/integrated_rnasamples_ann.rds" \
21 | --out_path "/beegfs/work/hd_wh241/MI_revisions/results/ct_data/Fib/Fib_states.rds" \
22 | --out_fig_file "/beegfs/work/hd_wh241/MI_revisions/results/ct_data/Fib/Fib_states.pdf" \
23 | --cell_class "Fib" \
24 | --class_label "cell_type" \
25 | --start_res 0.5;
26 |
27 | $CONDA_PREFIX/bin/Rscript ./analysis/utils/h5ad_mirrors.R \
28 | --scell_data "/beegfs/work/hd_wh241/MI_revisions/results/ct_data/Fib/Fib_states.rds" \
29 | --out_file "/beegfs/work/hd_wh241/MI_revisions/results/ct_data/Fib/Fib_states.h5ad";
30 |
31 | $CONDA_PREFIX/bin/Rscript ./analysis/utils/sce_mirrors.R \
32 | --seurat_file "/beegfs/work/hd_wh241/MI_revisions/results/ct_data/Fib/Fib_states.rds" \
33 | --sce_folder "/beegfs/work/hd_wh241/MI_revisions/results/ct_data/Fib/Fib_states_sce" \
34 | --assay "RNA" \
35 | --reduction "umap";
36 |
37 | $CONDA_PREFIX/bin/Rscript ./analysis/6_atlas_comparison/get_pseudobulk_profiles.R \
38 | --path "/beegfs/work/hd_wh241/MI_revisions/results/ct_data/Fib/Fib_states.rds" \
39 | --vars "orig.ident,opt_state" \
40 | --collapsed "yes" \
41 | --out_path "/beegfs/work/hd_wh241/MI_revisions/results/ct_data/Fib/ps_Fib_states.rds" \
42 | --def_assay "RNA";
43 |
--------------------------------------------------------------------------------
/st_snRNAseq/jobs/get_cellstates_fibro_bis.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | #PBS -l nodes=1:ppn=8
3 | #PBS -l walltime=08:00:00
4 | #PBS -l mem=150gb
5 | #PBS -S /bin/bash
6 | #PBS -N cell_states
7 | #PBS -o /beegfs/work/hd_wh241/MI_revisions/analysis/jobs/get_cellstates_Fib.out
8 | #PBS -e /beegfs/work/hd_wh241/MI_revisions/analysis/jobs/get_cellstates_Fib.err
9 | #PBS -q smp
10 | #PBS -m bea
11 | #PBS -M roramirezf@uni-heidelberg.de
12 |
13 | source ~/.bashrc;
14 | conda activate sc_analysis;
15 | cd /beegfs/work/hd_wh241/MI_revisions;
16 |
17 | $CONDA_PREFIX/bin/Rscript ./analysis/utils/sce_mirrors.R \
18 | --seurat_file "/beegfs/work/hd_wh241/MI_revisions/results/ct_data/Fib/Fib_states.rds" \
19 | --sce_folder "/beegfs/work/hd_wh241/MI_revisions/results/ct_data/Fib/Fib_states_sce" \
20 | --assay "RNA" \
21 | --reduction "umap";
22 |
23 |
--------------------------------------------------------------------------------
/st_snRNAseq/jobs/get_cellstates_fibro_filt.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | #PBS -l nodes=1:ppn=8
3 | #PBS -l walltime=08:00:00
4 | #PBS -l mem=150gb
5 | #PBS -S /bin/bash
6 | #PBS -N cell_states
7 | #PBS -o /beegfs/work/hd_wh241/MI_revisions/analysis/jobs/get_cellstates_filt_Fib.out
8 | #PBS -e /beegfs/work/hd_wh241/MI_revisions/analysis/jobs/get_cellstates_filt_Fib.err
9 | #PBS -q smp
10 | #PBS -m bea
11 | #PBS -M roramirezf@uni-heidelberg.de
12 |
13 | source ~/.bashrc;
14 | conda activate sc_analysis;
15 | cd /beegfs/work/hd_wh241/MI_revisions;
16 |
17 | mkdir ./results/ct_data_filt/Fib;
18 |
19 | $CONDA_PREFIX/bin/Rscript ./analysis/10_cellstates/get_filtered_states.R \
20 | --data_path "/beegfs/work/hd_wh241/MI_revisions/results/ct_data/Fib/Fib_states.rds" \
21 | --out_path "/beegfs/work/hd_wh241/MI_revisions/results/ct_data_filt/Fib/Fib_states.rds" \
22 | --out_fig_file "/beegfs/work/hd_wh241/MI_revisions/results/ct_data_filt/Fib/Fib_states.pdf" \
23 | --cell_class_excl "0,2,7" \
24 | --class_label "opt_state" \
25 | --start_res 0.3;
26 |
27 | $CONDA_PREFIX/bin/Rscript ./analysis/utils/h5ad_mirrors.R \
28 | --scell_data "/beegfs/work/hd_wh241/MI_revisions/results/ct_data_filt/Fib/Fib_states.rds" \
29 | --out_file "/beegfs/work/hd_wh241/MI_revisions/results/ct_data_filt/Fib/Fib_states.h5ad";
30 |
31 | $CONDA_PREFIX/bin/Rscript ./analysis/utils/sce_mirrors.R \
32 | --seurat_file "/beegfs/work/hd_wh241/MI_revisions/results/ct_data_filt/Fib/Fib_states.rds" \
33 | --sce_folder "/beegfs/work/hd_wh241/MI_revisions/results/ct_data_filt/Fib/Fib_states_sce" \
34 | --assay "RNA" \
35 | --reduction "umap";
36 |
37 | $CONDA_PREFIX/bin/Rscript ./analysis/6_atlas_comparison/get_pseudobulk_profiles.R \
38 | --path "/beegfs/work/hd_wh241/MI_revisions/results/ct_data_filt/Fib/Fib_states.rds" \
39 | --vars "orig.ident,opt_state" \
40 | --collapsed "yes" \
41 | --out_path "/beegfs/work/hd_wh241/MI_revisions/results/ct_data_filt/Fib/ps_Fib_states.rds" \
42 | --def_assay "RNA";
43 |
--------------------------------------------------------------------------------
/st_snRNAseq/jobs/get_cellstates_immune.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | #PBS -l nodes=1:ppn=8
3 | #PBS -l walltime=08:00:00
4 | #PBS -l mem=150gb
5 | #PBS -S /bin/bash
6 | #PBS -N cell_states
7 | #PBS -o /beegfs/work/hd_wh241/MI_revisions/analysis/jobs/get_cellstates_immune.out
8 | #PBS -e /beegfs/work/hd_wh241/MI_revisions/analysis/jobs/get_cellstates_immune.err
9 | #PBS -q smp
10 | #PBS -m bea
11 | #PBS -M roramirezf@uni-heidelberg.de
12 |
13 | source ~/.bashrc;
14 | conda activate sc_analysis;
15 | cd /beegfs/work/hd_wh241/MI_revisions;
16 |
17 | mkdir ./results/ct_data/immune;
18 |
19 | $CONDA_PREFIX/bin/Rscript ./analysis/2_snuc_integration_harmony/get_cell_states.R \
20 | --data_path "/beegfs/work/hd_wh241/MI_revisions/processed_snrnaseq/integration/integrated_rnasamples_ann.rds" \
21 | --out_path "/beegfs/work/hd_wh241/MI_revisions/results/ct_data/immune/immune_states.rds" \
22 | --out_fig_file "/beegfs/work/hd_wh241/MI_revisions/results/ct_data/immune/immune_states.pdf" \
23 | --cell_class "Mast,Myeloid" \
24 | --class_label "cell_type" \
25 | --start_res 0.5;
26 |
27 | $CONDA_PREFIX/bin/Rscript ./analysis/utils/h5ad_mirrors.R \
28 | --scell_data "/beegfs/work/hd_wh241/MI_revisions/results/ct_data/immune/immune_states.rds" \
29 | --out_file "/beegfs/work/hd_wh241/MI_revisions/results/ct_data/immune/immune_states.h5ad";
30 |
31 | $CONDA_PREFIX/bin/Rscript ./analysis/utils/sce_mirrors.R \
32 | --seurat_file "/beegfs/work/hd_wh241/MI_revisions/results/ct_data/immune/immune_states.rds" \
33 | --sce_folder "/beegfs/work/hd_wh241/MI_revisions/results/ct_data/immune/immune_states_sce" \
34 | --assay "RNA" \
35 | --reduction "umap";
36 |
37 | $CONDA_PREFIX/bin/Rscript ./analysis/6_atlas_comparison/get_pseudobulk_profiles.R \
38 | --path "/beegfs/work/hd_wh241/MI_revisions/results/ct_data/immune/immune_states.rds" \
39 | --vars "orig.ident,opt_state" \
40 | --collapsed "yes" \
41 | --out_path "/beegfs/work/hd_wh241/MI_revisions/results/ct_data/immune/ps_immune_states.rds" \
42 | --def_assay "RNA";
43 |
--------------------------------------------------------------------------------
/st_snRNAseq/jobs/get_cellstates_lymphoid.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | #PBS -l nodes=1:ppn=8
3 | #PBS -l walltime=08:00:00
4 | #PBS -l mem=150gb
5 | #PBS -S /bin/bash
6 | #PBS -N cell_states
7 | #PBS -o /beegfs/work/hd_wh241/MI_revisions/analysis/jobs/get_cellstates_Lymphoid.out
8 | #PBS -e /beegfs/work/hd_wh241/MI_revisions/analysis/jobs/get_cellstates_Lymphoid.err
9 | #PBS -q smp
10 | #PBS -m bea
11 | #PBS -M roramirezf@uni-heidelberg.de
12 |
13 | source ~/.bashrc;
14 | conda activate sc_analysis;
15 | cd /beegfs/work/hd_wh241/MI_revisions;
16 |
17 | mkdir ./results/ct_data/Lymphoid;
18 |
19 | $CONDA_PREFIX/bin/Rscript ./analysis/2_snuc_integration_harmony/get_cell_states.R \
20 | --data_path "/beegfs/work/hd_wh241/MI_revisions/processed_snrnaseq/integration/integrated_rnasamples_ann.rds" \
21 | --out_path "/beegfs/work/hd_wh241/MI_revisions/results/ct_data/Lymphoid/Lymphoid_states.rds" \
22 | --out_fig_file "/beegfs/work/hd_wh241/MI_revisions/results/ct_data/Lymphoid/Lymphoid_states.pdf" \
23 | --cell_class "Lymphoid" \
24 | --class_label "cell_type" \
25 | --start_res 0.5;
26 |
27 | $CONDA_PREFIX/bin/Rscript ./analysis/utils/h5ad_mirrors.R \
28 | --scell_data "/beegfs/work/hd_wh241/MI_revisions/results/ct_data/Lymphoid/Lymphoid_states.rds" \
29 | --out_file "/beegfs/work/hd_wh241/MI_revisions/results/ct_data/Lymphoid/Lymphoid_states.h5ad";
30 |
31 | $CONDA_PREFIX/bin/Rscript ./analysis/utils/sce_mirrors.R \
32 | --seurat_file "/beegfs/work/hd_wh241/MI_revisions/results/ct_data/Lymphoid/Lymphoid_states.rds" \
33 | --sce_folder "/beegfs/work/hd_wh241/MI_revisions/results/ct_data/Lymphoid/Lymphoid_states_sce" \
34 | --assay "RNA" \
35 | --reduction "umap";
36 |
37 | $CONDA_PREFIX/bin/Rscript ./analysis/6_atlas_comparison/get_pseudobulk_profiles.R \
38 | --path "/beegfs/work/hd_wh241/MI_revisions/results/ct_data/Lymphoid/Lymphoid_states.rds" \
39 | --vars "orig.ident,opt_state" \
40 | --collapsed "yes" \
41 | --out_path "/beegfs/work/hd_wh241/MI_revisions/results/ct_data/Lymphoid/ps_Lymphoid_states.rds" \
42 | --def_assay "RNA";
43 |
--------------------------------------------------------------------------------
/st_snRNAseq/jobs/get_cellstates_lymphoid_filt.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | #PBS -l nodes=1:ppn=8
3 | #PBS -l walltime=08:00:00
4 | #PBS -l mem=150gb
5 | #PBS -S /bin/bash
6 | #PBS -N cell_states
7 | #PBS -o /beegfs/work/hd_wh241/MI_revisions/analysis/jobs/get_cellstates_filt_Lymphoid.out
8 | #PBS -e /beegfs/work/hd_wh241/MI_revisions/analysis/jobs/get_cellstates_filt_Lymphoid.err
9 | #PBS -q smp
10 | #PBS -m bea
11 | #PBS -M roramirezf@uni-heidelberg.de
12 |
13 | source ~/.bashrc;
14 | conda activate sc_analysis;
15 | cd /beegfs/work/hd_wh241/MI_revisions;
16 |
17 | mkdir ./results/ct_data_filt/Lymphoid;
18 |
19 | $CONDA_PREFIX/bin/Rscript ./analysis/10_cellstates/get_filtered_states.R \
20 | --data_path "/beegfs/work/hd_wh241/MI_revisions/results/ct_data/Lymphoid/Lymphoid_states.rds" \
21 | --out_path "/beegfs/work/hd_wh241/MI_revisions/results/ct_data_filt/Lymphoid/Lymphoid_states.rds" \
22 | --out_fig_file "/beegfs/work/hd_wh241/MI_revisions/results/ct_data_filt/Lymphoid/Lymphoid_states.pdf" \
23 | --cell_class_excl "0,3,4" \
24 | --class_label "opt_state" \
25 | --start_res 0.1;
26 |
27 | $CONDA_PREFIX/bin/Rscript ./analysis/utils/h5ad_mirrors.R \
28 | --scell_data "/beegfs/work/hd_wh241/MI_revisions/results/ct_data_filt/Lymphoid/Lymphoid_states.rds" \
29 | --out_file "/beegfs/work/hd_wh241/MI_revisions/results/ct_data_filt/Lymphoid/Lymphoid_states.h5ad";
30 |
31 | $CONDA_PREFIX/bin/Rscript ./analysis/utils/sce_mirrors.R \
32 | --seurat_file "/beegfs/work/hd_wh241/MI_revisions/results/ct_data_filt/Lymphoid/Lymphoid_states.rds" \
33 | --sce_folder "/beegfs/work/hd_wh241/MI_revisions/results/ct_data_filt/Lymphoid/Lymphoid_states_sce" \
34 | --assay "RNA" \
35 | --reduction "umap";
36 |
37 | $CONDA_PREFIX/bin/Rscript ./analysis/6_atlas_comparison/get_pseudobulk_profiles.R \
38 | --path "/beegfs/work/hd_wh241/MI_revisions/results/ct_data_filt/Lymphoid/Lymphoid_states.rds" \
39 | --vars "orig.ident,opt_state" \
40 | --collapsed "yes" \
41 | --out_path "/beegfs/work/hd_wh241/MI_revisions/results/ct_data_filt/Lymphoid/ps_Lymphoid_states.rds" \
42 | --def_assay "RNA";
43 |
--------------------------------------------------------------------------------
/st_snRNAseq/jobs/get_cellstates_macrophages.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | #PBS -l nodes=1:ppn=8
3 | #PBS -l walltime=08:00:00
4 | #PBS -l mem=150gb
5 | #PBS -S /bin/bash
6 | #PBS -N cell_states
7 | #PBS -o /beegfs/work/hd_wh241/MI_revisions/analysis/jobs/get_cellstates_macro.out
8 | #PBS -e /beegfs/work/hd_wh241/MI_revisions/analysis/jobs/get_cellstates_macro.err
9 | #PBS -q smp
10 | #PBS -m bea
11 | #PBS -M roramirezf@uni-heidelberg.de
12 |
13 | source ~/.bashrc;
14 | conda activate sc_analysis;
15 | cd /beegfs/work/hd_wh241/MI_revisions;
16 |
17 | mkdir ./results/ct_data/macrophages;
18 |
19 | $CONDA_PREFIX/bin/Rscript ./analysis/2_snuc_integration_harmony/get_cell_states.R \
20 | --data_path "/beegfs/work/hd_wh241/MI_revisions/processed_snrnaseq/integration/integrated_rnasamples_ann.rds" \
21 | --out_path "/beegfs/work/hd_wh241/MI_revisions/results/ct_data/macrophages/macrophages_states.rds" \
22 | --out_fig_file "/beegfs/work/hd_wh241/MI_revisions/results/ct_data/macrophages/macrophages_states.pdf" \
23 | --cell_class "macrophages" \
24 | --class_label "cell_type" \
25 | --start_res 0.2;
26 |
27 | $CONDA_PREFIX/bin/Rscript ./analysis/utils/h5ad_mirrors.R \
28 | --scell_data "/beegfs/work/hd_wh241/MI_revisions/results/ct_data/macrophages/macrophages_states.rds" \
29 | --out_file "/beegfs/work/hd_wh241/MI_revisions/results/ct_data/macrophages/macrophages_states.h5ad";
30 |
31 | $CONDA_PREFIX/bin/Rscript ./analysis/utils/sce_mirrors.R \
32 | --seurat_file "/beegfs/work/hd_wh241/MI_revisions/results/ct_data/macrophages/macrophages_states.rds" \
33 | --sce_folder "/beegfs/work/hd_wh241/MI_revisions/results/ct_data/macrophages/macrophages_states_sce" \
34 | --assay "RNA" \
35 | --reduction "umap";
36 |
37 | $CONDA_PREFIX/bin/Rscript ./analysis/6_atlas_comparison/get_pseudobulk_profiles.R \
38 | --path "/beegfs/work/hd_wh241/MI_revisions/results/ct_data/macrophages/macrophages_states.rds" \
39 | --vars "orig.ident,opt_state" \
40 | --collapsed "yes" \
41 | --out_path "/beegfs/work/hd_wh241/MI_revisions/results/ct_data/macrophages/ps_macrophages_states.rds" \
42 | --def_assay "RNA";
43 |
--------------------------------------------------------------------------------
/st_snRNAseq/jobs/get_cellstates_mirrors.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | #PBS -l nodes=1:ppn=8
3 | #PBS -l walltime=05:00:00
4 | #PBS -l mem=130gb
5 | #PBS -S /bin/bash
6 | #PBS -N cell_states
7 | #PBS -o /beegfs/work/hd_wh241/MI_revisions/analysis/jobs/get_cellstates_mirrors.out
8 | #PBS -e /beegfs/work/hd_wh241/MI_revisions/analysis/jobs/get_cellstates_mirrors.err
9 | #PBS -q smp
10 | #PBS -m bea
11 | #PBS -M roramirezf@uni-heidelberg.de
12 |
13 | source ~/.bashrc;
14 | conda activate sc_analysis;
15 | cd /beegfs/work/hd_wh241/MI_revisions;
16 |
17 | for i in {cardiomyocyte,endothelial,fibroblast}
18 | do
19 | $CONDA_PREFIX/bin/Rscript ./analysis/utils/h5ad_mirrors.R \
20 | --scell_data "/beegfs/work/hd_wh241/MI_revisions/results/ct_data/${i}/${i}_states.rds" \
21 | --out_file "/beegfs/work/hd_wh241/MI_revisions/results/ct_data/${i}/${i}_states.h5ad";
22 |
23 | $CONDA_PREFIX/bin/Rscript ./analysis/utils/sce_mirrors.R \
24 | --seurat_file "/beegfs/work/hd_wh241/MI_revisions/results/ct_data/${i}/${i}_states.rds" \
25 | --sce_folder "/beegfs/work/hd_wh241/MI_revisions/results/ct_data/${i}/${i}_states_sce" \
26 | --assay "RNA" \
27 | --reduction "umap";
28 |
29 | $CONDA_PREFIX/bin/Rscript ./analysis/6_atlas_comparison/get_pseudobulk_profiles.R \
30 | --path "/beegfs/work/hd_wh241/MI_revisions/results/ct_data/${i}/${i}_states.rds" \
31 | --vars "orig.ident,opt_state" \
32 | --collapsed "yes" \
33 | --out_path "/beegfs/work/hd_wh241/MI_revisions/results/ct_data/${i}/ps_${i}_states.rds" \
34 | --def_assay "RNA";
35 |
36 | done
37 |
--------------------------------------------------------------------------------
/st_snRNAseq/jobs/get_cellstates_myeloid.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | #PBS -l nodes=1:ppn=8
3 | #PBS -l walltime=08:00:00
4 | #PBS -l mem=150gb
5 | #PBS -S /bin/bash
6 | #PBS -N cell_states
7 | #PBS -o /beegfs/work/hd_wh241/MI_revisions/analysis/jobs/get_cellstates_Myeloid.out
8 | #PBS -e /beegfs/work/hd_wh241/MI_revisions/analysis/jobs/get_cellstates_Myeloid.err
9 | #PBS -q smp
10 | #PBS -m bea
11 | #PBS -M roramirezf@uni-heidelberg.de
12 |
13 | source ~/.bashrc;
14 | conda activate sc_analysis;
15 | cd /beegfs/work/hd_wh241/MI_revisions;
16 |
17 | mkdir ./results/ct_data/Myeloid;
18 |
19 | $CONDA_PREFIX/bin/Rscript ./analysis/2_snuc_integration_harmony/get_cell_states.R \
20 | --data_path "/beegfs/work/hd_wh241/MI_revisions/processed_snrnaseq/integration/integrated_rnasamples_ann.rds" \
21 | --out_path "/beegfs/work/hd_wh241/MI_revisions/results/ct_data/Myeloid/Myeloid_states.rds" \
22 | --out_fig_file "/beegfs/work/hd_wh241/MI_revisions/results/ct_data/Myeloid/Myeloid_states.pdf" \
23 | --cell_class "Myeloid,Mast" \
24 | --class_label "cell_type" \
25 | --start_res 0.5;
26 |
27 | $CONDA_PREFIX/bin/Rscript ./analysis/utils/h5ad_mirrors.R \
28 | --scell_data "/beegfs/work/hd_wh241/MI_revisions/results/ct_data/Myeloid/Myeloid_states.rds" \
29 | --out_file "/beegfs/work/hd_wh241/MI_revisions/results/ct_data/Myeloid/Myeloid_states.h5ad";
30 |
31 | $CONDA_PREFIX/bin/Rscript ./analysis/utils/sce_mirrors.R \
32 | --seurat_file "/beegfs/work/hd_wh241/MI_revisions/results/ct_data/Myeloid/Myeloid_states.rds" \
33 | --sce_folder "/beegfs/work/hd_wh241/MI_revisions/results/ct_data/Myeloid/Myeloid_states_sce" \
34 | --assay "RNA" \
35 | --reduction "umap";
36 |
37 | $CONDA_PREFIX/bin/Rscript ./analysis/6_atlas_comparison/get_pseudobulk_profiles.R \
38 | --path "/beegfs/work/hd_wh241/MI_revisions/results/ct_data/Myeloid/Myeloid_states.rds" \
39 | --vars "orig.ident,opt_state" \
40 | --collapsed "yes" \
41 | --out_path "/beegfs/work/hd_wh241/MI_revisions/results/ct_data/Myeloid/ps_Myeloid_states.rds" \
42 | --def_assay "RNA";
43 |
--------------------------------------------------------------------------------
/st_snRNAseq/jobs/get_cellstates_myeloid_filt.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | #PBS -l nodes=1:ppn=8
3 | #PBS -l walltime=08:00:00
4 | #PBS -l mem=150gb
5 | #PBS -S /bin/bash
6 | #PBS -N cell_states
7 | #PBS -o /beegfs/work/hd_wh241/MI_revisions/analysis/jobs/get_cellstates_filt_Myeloid.out
8 | #PBS -e /beegfs/work/hd_wh241/MI_revisions/analysis/jobs/get_cellstates_filt_Myeloid.err
9 | #PBS -q smp
10 | #PBS -m bea
11 | #PBS -M roramirezf@uni-heidelberg.de
12 |
13 | source ~/.bashrc;
14 | conda activate sc_analysis;
15 | cd /beegfs/work/hd_wh241/MI_revisions;
16 |
17 | mkdir ./results/ct_data_filt/Myeloid;
18 |
19 | $CONDA_PREFIX/bin/Rscript ./analysis/10_cellstates/get_filtered_states.R \
20 | --data_path "/beegfs/work/hd_wh241/MI_revisions/results/ct_data/Myeloid/Myeloid_states.rds" \
21 | --out_path "/beegfs/work/hd_wh241/MI_revisions/results/ct_data_filt/Myeloid/Myeloid_states.rds" \
22 | --out_fig_file "/beegfs/work/hd_wh241/MI_revisions/results/ct_data_filt/Myeloid/Myeloid_states.pdf" \
23 | --cell_class_excl "0,11,13,15,16" \
24 | --class_label "opt_state" \
25 | --start_res 0.3;
26 |
27 | $CONDA_PREFIX/bin/Rscript ./analysis/utils/h5ad_mirrors.R \
28 | --scell_data "/beegfs/work/hd_wh241/MI_revisions/results/ct_data_filt/Myeloid/Myeloid_states.rds" \
29 | --out_file "/beegfs/work/hd_wh241/MI_revisions/results/ct_data_filt/Myeloid/Myeloid_states.h5ad";
30 |
31 | $CONDA_PREFIX/bin/Rscript ./analysis/utils/sce_mirrors.R \
32 | --seurat_file "/beegfs/work/hd_wh241/MI_revisions/results/ct_data_filt/Myeloid/Myeloid_states.rds" \
33 | --sce_folder "/beegfs/work/hd_wh241/MI_revisions/results/ct_data_filt/Myeloid/Myeloid_states_sce" \
34 | --assay "RNA" \
35 | --reduction "umap";
36 |
37 | $CONDA_PREFIX/bin/Rscript ./analysis/6_atlas_comparison/get_pseudobulk_profiles.R \
38 | --path "/beegfs/work/hd_wh241/MI_revisions/results/ct_data_filt/Myeloid/Myeloid_states.rds" \
39 | --vars "orig.ident,opt_state" \
40 | --collapsed "yes" \
41 | --out_path "/beegfs/work/hd_wh241/MI_revisions/results/ct_data_filt/Myeloid/ps_Myeloid_states.rds" \
42 | --def_assay "RNA";
43 |
--------------------------------------------------------------------------------
/st_snRNAseq/jobs/get_cellstates_pericytes.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | #PBS -l nodes=1:ppn=8
3 | #PBS -l walltime=08:00:00
4 | #PBS -l mem=150gb
5 | #PBS -S /bin/bash
6 | #PBS -N cell_states
7 | #PBS -o /beegfs/work/hd_wh241/MI_revisions/analysis/jobs/get_cellstates_PC.out
8 | #PBS -e /beegfs/work/hd_wh241/MI_revisions/analysis/jobs/get_cellstates_PC.err
9 | #PBS -q smp
10 | #PBS -m bea
11 | #PBS -M roramirezf@uni-heidelberg.de
12 |
13 | source ~/.bashrc;
14 | conda activate sc_analysis;
15 | cd /beegfs/work/hd_wh241/MI_revisions;
16 |
17 | mkdir ./results/ct_data/PC;
18 |
19 | $CONDA_PREFIX/bin/Rscript ./analysis/2_snuc_integration_harmony/get_cell_states.R \
20 | --data_path "/beegfs/work/hd_wh241/MI_revisions/processed_snrnaseq/integration/integrated_rnasamples_ann.rds" \
21 | --out_path "/beegfs/work/hd_wh241/MI_revisions/results/ct_data/PC/PC_states.rds" \
22 | --out_fig_file "/beegfs/work/hd_wh241/MI_revisions/results/ct_data/PC/PC_states.pdf" \
23 | --cell_class "PC" \
24 | --class_label "cell_type" \
25 | --start_res 0.1;
26 |
27 | $CONDA_PREFIX/bin/Rscript ./analysis/utils/h5ad_mirrors.R \
28 | --scell_data "/beegfs/work/hd_wh241/MI_revisions/results/ct_data/PC/PC_states.rds" \
29 | --out_file "/beegfs/work/hd_wh241/MI_revisions/results/ct_data/PC/PC_states.h5ad";
30 |
31 | $CONDA_PREFIX/bin/Rscript ./analysis/utils/sce_mirrors.R \
32 | --seurat_file "/beegfs/work/hd_wh241/MI_revisions/results/ct_data/PC/PC_states.rds" \
33 | --sce_folder "/beegfs/work/hd_wh241/MI_revisions/results/ct_data/PC/PC_states_sce" \
34 | --assay "RNA" \
35 | --reduction "umap";
36 |
37 | $CONDA_PREFIX/bin/Rscript ./analysis/6_atlas_comparison/get_pseudobulk_profiles.R \
38 | --path "/beegfs/work/hd_wh241/MI_revisions/results/ct_data/PC/PC_states.rds" \
39 | --vars "orig.ident,opt_state" \
40 | --collapsed "yes" \
41 | --out_path "/beegfs/work/hd_wh241/MI_revisions/results/ct_data/PC/ps_PC_states.rds" \
42 | --def_assay "RNA";
43 |
--------------------------------------------------------------------------------
/st_snRNAseq/jobs/get_cellstates_vsmcs.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | #PBS -l nodes=1:ppn=8
3 | #PBS -l walltime=08:00:00
4 | #PBS -l mem=150gb
5 | #PBS -S /bin/bash
6 | #PBS -N cell_states
7 | #PBS -o /beegfs/work/hd_wh241/MI_revisions/analysis/jobs/get_cellstates_vSMCs.out
8 | #PBS -e /beegfs/work/hd_wh241/MI_revisions/analysis/jobs/get_cellstates_vSMCs.err
9 | #PBS -q smp
10 | #PBS -m bea
11 | #PBS -M roramirezf@uni-heidelberg.de
12 |
13 | source ~/.bashrc;
14 | conda activate sc_analysis;
15 | cd /beegfs/work/hd_wh241/MI_revisions;
16 |
17 | mkdir ./results/ct_data/vSMCs;
18 |
19 | $CONDA_PREFIX/bin/Rscript ./analysis/2_snuc_integration_harmony/get_cell_states.R \
20 | --data_path "/beegfs/work/hd_wh241/MI_revisions/processed_snrnaseq/integration/integrated_rnasamples_ann.rds" \
21 | --out_path "/beegfs/work/hd_wh241/MI_revisions/results/ct_data/vSMCs/vSMCs_states.rds" \
22 | --out_fig_file "/beegfs/work/hd_wh241/MI_revisions/results/ct_data/vSMCs/vSMCs_states.pdf" \
23 | --cell_class "vSMCs" \
24 | --class_label "cell_type" \
25 | --start_res 0.1;
26 |
27 | $CONDA_PREFIX/bin/Rscript ./analysis/utils/h5ad_mirrors.R \
28 | --scell_data "/beegfs/work/hd_wh241/MI_revisions/results/ct_data/vSMCs/vSMCs_states.rds" \
29 | --out_file "/beegfs/work/hd_wh241/MI_revisions/results/ct_data/vSMCs/vSMCs_states.h5ad";
30 |
31 | $CONDA_PREFIX/bin/Rscript ./analysis/utils/sce_mirrors.R \
32 | --seurat_file "/beegfs/work/hd_wh241/MI_revisions/results/ct_data/vSMCs/vSMCs_states.rds" \
33 | --sce_folder "/beegfs/work/hd_wh241/MI_revisions/results/ct_data/vSMCs/vSMCs_states_sce" \
34 | --assay "RNA" \
35 | --reduction "umap";
36 |
37 | $CONDA_PREFIX/bin/Rscript ./analysis/6_atlas_comparison/get_pseudobulk_profiles.R \
38 | --path "/beegfs/work/hd_wh241/MI_revisions/results/ct_data/vSMCs/vSMCs_states.rds" \
39 | --vars "orig.ident,opt_state" \
40 | --collapsed "yes" \
41 | --out_path "/beegfs/work/hd_wh241/MI_revisions/results/ct_data/vSMCs/ps_vSMCs_states.rds" \
42 | --def_assay "RNA";
43 |
--------------------------------------------------------------------------------
/st_snRNAseq/jobs/get_dfuncs_cardio.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | #PBS -l nodes=1:ppn=8
3 | #PBS -l walltime=06:00:00
4 | #PBS -l mem=150gb
5 | #PBS -S /bin/bash
6 | #PBS -N cell_states
7 | #PBS -o /beegfs/work/hd_wh241/MI_revisions/analysis/jobs/get_dfuncs_cardio.out
8 | #PBS -e /beegfs/work/hd_wh241/MI_revisions/analysis/jobs/get_dfuncs_cardio.err
9 | #PBS -q smp
10 | #PBS -m bea
11 | #PBS -M roramirezf@uni-heidelberg.de
12 |
13 | source ~/.bashrc;
14 | conda activate sc_analysis;
15 | cd /beegfs/work/hd_wh241/MI_revisions;
16 |
17 | mkdir ./results/ct_data/cardiomyocyte;
18 |
19 | $CONDA_PREFIX/bin/Rscript ./analysis/3_functional_characterization/add_funcomics_largedata.R \
20 | --data_path "/beegfs/work/hd_wh241/MI_revisions/results/ct_data/cardiomyocyte/cardiomyocyte_states.rds" \
21 | --out_path "/beegfs/work/hd_wh241/MI_revisions/results/ct_data/cardiomyocyte/cardiomyocyte_states.rds" \
22 | --group_class "opt_state" \
23 | --gene_set_collection "not";
24 |
25 | $CONDA_PREFIX/bin/Rscript ./analysis/3_functional_characterization/estimate_dea.R \
26 | --data_path "/beegfs/work/hd_wh241/MI_revisions/results/ct_data/cardiomyocyte/cardiomyocyte_states.rds" \
27 | --out_df "/beegfs/work/hd_wh241/MI_revisions/results/ct_data/cardiomyocyte/cardiomyocyte_dea.rds" \
28 | --test_assays "RNA,progeny,dorothea" \
29 | --group_class "opt_state" \
30 | --lfc "0.20" \
31 | --only_pos "yes";
32 |
33 | $CONDA_PREFIX/bin/Rscript ./analysis/3_functional_characterization/plot_funcomics.R \
34 | --data_path "/beegfs/work/hd_wh241/MI_revisions/results/ct_data/cardiomyocyte/cardiomyocyte_states.rds" \
35 | --dea_data_path "/beegfs/work/hd_wh241/MI_revisions/results/ct_data/cardiomyocyte/cardiomyocyte_dea.rds" \
36 | --nfeats 10 \
37 | --ngenes_ORA 10 \
38 | --pvalue_ORA 0.15 \
39 | --pvalue 0.001 \
40 | --lfc 0.5 \
41 | --test_assays "RNA,progeny,dorothea" \
42 | --group_class "opt_state" \
43 | --out_path "/beegfs/work/hd_wh241/MI_revisions/results/ct_data/cardiomyocyte/cardiomyocyte";
44 |
--------------------------------------------------------------------------------
/st_snRNAseq/jobs/get_dfuncs_endo.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | #PBS -l nodes=1:ppn=8
3 | #PBS -l walltime=06:00:00
4 | #PBS -l mem=150gb
5 | #PBS -S /bin/bash
6 | #PBS -N cell_states
7 | #PBS -o /beegfs/work/hd_wh241/MI_revisions/analysis/jobs/get_dfuncs_endo.out
8 | #PBS -e /beegfs/work/hd_wh241/MI_revisions/analysis/jobs/get_dfuncs_endo.err
9 | #PBS -q smp
10 | #PBS -m bea
11 | #PBS -M roramirezf@uni-heidelberg.de
12 |
13 | source ~/.bashrc;
14 | conda activate sc_analysis;
15 | cd /beegfs/work/hd_wh241/MI_revisions;
16 |
17 | mkdir ./results/ct_data/endothelial;
18 |
19 | $CONDA_PREFIX/bin/Rscript ./analysis/3_functional_characterization/add_funcomics_largedata.R \
20 | --data_path "/beegfs/work/hd_wh241/MI_revisions/results/ct_data/endothelial/endothelial_states.rds" \
21 | --out_path "/beegfs/work/hd_wh241/MI_revisions/results/ct_data/endothelial/endothelial_states.rds" \
22 | --group_class "opt_state" \
23 | --gene_set_collection "not";
24 |
25 | $CONDA_PREFIX/bin/Rscript ./analysis/3_functional_characterization/estimate_dea.R \
26 | --data_path "/beegfs/work/hd_wh241/MI_revisions/results/ct_data/endothelial/endothelial_states.rds" \
27 | --out_df "/beegfs/work/hd_wh241/MI_revisions/results/ct_data/endothelial/endothelial_dea.rds" \
28 | --test_assays "RNA,progeny,dorothea" \
29 | --group_class "opt_state" \
30 | --lfc "0.20" \
31 | --only_pos "yes";
32 |
33 | $CONDA_PREFIX/bin/Rscript ./analysis/3_functional_characterization/plot_funcomics.R \
34 | --data_path "/beegfs/work/hd_wh241/MI_revisions/results/ct_data/endothelial/endothelial_states.rds" \
35 | --dea_data_path "/beegfs/work/hd_wh241/MI_revisions/results/ct_data/endothelial/endothelial_dea.rds" \
36 | --nfeats 10 \
37 | --ngenes_ORA 10 \
38 | --pvalue_ORA 0.15 \
39 | --pvalue 0.001 \
40 | --lfc 0.5 \
41 | --test_assays "RNA,progeny,dorothea" \
42 | --group_class "opt_state" \
43 | --out_path "/beegfs/work/hd_wh241/MI_revisions/results/ct_data/endothelial/endothelial";
44 |
--------------------------------------------------------------------------------
/st_snRNAseq/jobs/get_dfuncs_fibro.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | #PBS -l nodes=1:ppn=8
3 | #PBS -l walltime=06:00:00
4 | #PBS -l mem=150gb
5 | #PBS -S /bin/bash
6 | #PBS -N cell_states
7 | #PBS -o /beegfs/work/hd_wh241/MI_revisions/analysis/jobs/get_dfuncs_fibro.out
8 | #PBS -e /beegfs/work/hd_wh241/MI_revisions/analysis/jobs/get_dfuncs_fibro.err
9 | #PBS -q smp
10 | #PBS -m bea
11 | #PBS -M roramirezf@uni-heidelberg.de
12 |
13 | source ~/.bashrc;
14 | conda activate sc_analysis;
15 | cd /beegfs/work/hd_wh241/MI_revisions;
16 |
17 | mkdir ./results/ct_data/fibroblast;
18 |
19 | $CONDA_PREFIX/bin/Rscript ./analysis/3_functional_characterization/add_funcomics_largedata.R \
20 | --data_path "/beegfs/work/hd_wh241/MI_revisions/results/ct_data/fibroblast/fibroblast_states.rds" \
21 | --out_path "/beegfs/work/hd_wh241/MI_revisions/results/ct_data/fibroblast/fibroblast_states.rds" \
22 | --group_class "opt_state" \
23 | --gene_set_collection "not";
24 |
25 | $CONDA_PREFIX/bin/Rscript ./analysis/3_functional_characterization/estimate_dea.R \
26 | --data_path "/beegfs/work/hd_wh241/MI_revisions/results/ct_data/fibroblast/fibroblast_states.rds" \
27 | --out_df "/beegfs/work/hd_wh241/MI_revisions/results/ct_data/fibroblast/fibroblast_dea.rds" \
28 | --test_assays "RNA,progeny,dorothea" \
29 | --group_class "opt_state" \
30 | --lfc "0.20" \
31 | --only_pos "yes";
32 |
33 | $CONDA_PREFIX/bin/Rscript ./analysis/3_functional_characterization/plot_funcomics.R \
34 | --data_path "/beegfs/work/hd_wh241/MI_revisions/results/ct_data/fibroblast/fibroblast_states.rds" \
35 | --dea_data_path "/beegfs/work/hd_wh241/MI_revisions/results/ct_data/fibroblast/fibroblast_dea.rds" \
36 | --nfeats 10 \
37 | --ngenes_ORA 10 \
38 | --pvalue_ORA 0.15 \
39 | --pvalue 0.001 \
40 | --lfc 0.5 \
41 | --test_assays "RNA,progeny,dorothea" \
42 | --group_class "opt_state" \
43 | --out_path "/beegfs/work/hd_wh241/MI_revisions/results/ct_data/fibroblast/fibroblast";
44 |
--------------------------------------------------------------------------------
/st_snRNAseq/jobs/get_integrated_annobj.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | #PBS -l nodes=1:ppn=16
3 | #PBS -l walltime=5:00:00
4 | #PBS -l mem=150gb
5 | #PBS -S /bin/bash
6 | #PBS -N visium_mrkr_estimation
7 | #PBS -o /beegfs/work/hd_wh241/MI_revisions/analysis/jobs/get_integrated_annobj.out
8 | #PBS -e /beegfs/work/hd_wh241/MI_revisions/analysis/jobs/get_integrated_annobj.err
9 | #PBS -q smp
10 | #PBS -m bea
11 | #PBS -M roramirezf@uni-heidelberg.de
12 |
13 | source ~/.bashrc;
14 | conda activate sc_analysis;
15 | cd /beegfs/work/hd_wh241/MI_revisions;
16 |
17 | $CONDA_PREFIX/bin/Rscript ./analysis/10_cellstates/get_integrated_annobj.R;
--------------------------------------------------------------------------------
/st_snRNAseq/jobs/get_snrna_pseudobulk.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | #PBS -l nodes=1:ppn=8
3 | #PBS -l walltime=04:00:00
4 | #PBS -l mem=150gb
5 | #PBS -S /bin/bash
6 | #PBS -N snrnapseudobulk
7 | #PBS -o /beegfs/work/hd_wh241/MI_revisions/analysis/jobs/get_snrna_pseudobulk.out
8 | #PBS -e /beegfs/work/hd_wh241/MI_revisions/analysis/jobs/get_snrna_pseudobulk.err
9 | #PBS -q smp
10 | #PBS -m bea
11 | #PBS -M roramirezf@uni-heidelberg.de
12 |
13 | source ~/.bashrc;
14 | conda activate sc_analysis;
15 | cd /beegfs/work/hd_wh241/MI_revisions;
16 |
17 | $CONDA_PREFIX/bin/Rscript ./analysis/6_atlas_comparison/get_pseudobulk_profiles.R \
18 | --path "/beegfs/work/hd_wh241/MI_revisions/processed_snrnaseq/integration/integrated_rnasamples_ann.rds" \
19 | --vars "cell_type" \
20 | --out_path "/beegfs/work/hd_wh241/MI_revisions/processed_snrnaseq/integration/ps_integrated_rnasamples_ann.rds" \
21 | --def_assay "RNA";
22 |
23 | $CONDA_PREFIX/bin/Rscript ./analysis/6_atlas_comparison/get_pseudobulk_profiles.R \
24 | --path "/beegfs/work/hd_wh241/MI_revisions/processed_snrnaseq/integration/integrated_rnasamples_ann.rds" \
25 | --vars "orig.ident,cell_type" \
26 | --collapsed "yes" \
27 | --out_path "/beegfs/work/hd_wh241/MI_revisions/processed_snrnaseq/integration/psxsmpl_integrated_rnasamples_ann.rds" \
28 | --def_assay "RNA";
29 |
--------------------------------------------------------------------------------
/st_snRNAseq/jobs/get_umap.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | #PBS -l nodes=1:ppn=4
3 | #PBS -l walltime=01:00:00
4 | #PBS -l mem=64gb
5 | #PBS -S /bin/bash
6 | #PBS -N spatial_pseudobulk
7 | #PBS -o /beegfs/work/hd_wh241/MI_revisions/analysis/jobs/get_umap.out
8 | #PBS -e /beegfs/work/hd_wh241/MI_revisions/analysis/jobs/get_umap.err
9 | #PBS -q short
10 | #PBS -m bea
11 | #PBS -M roramirezf@uni-heidelberg.de
12 |
13 | source ~/.bashrc;
14 | conda activate sc_analysis;
15 | cd /beegfs/work/hd_wh241/MI_revisions;
16 |
17 | $CONDA_PREFIX/bin/Rscript ./analysis/mini_tasks/get_umap_from_integration.R;
--------------------------------------------------------------------------------
/st_snRNAseq/jobs/klmiatlas_run_pipeline.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | #PBS -l nodes=1:ppn=4
3 | #PBS -l walltime=08:00:00
4 | #PBS -l mem=130gb
5 | #PBS -S /bin/bash
6 | #PBS -N single_snuc_proc
7 | #PBS -o /beegfs/work/hd_wh241/MI_revisions/analysis/jobs/klmiatlas_run_pipeline.out
8 | #PBS -e /beegfs/work/hd_wh241/MI_revisions/analysis/jobs/klmiatlas_run_pipeline.err
9 | #PBS -q smp
10 | #PBS -m bea
11 | #PBS -M roramirezf@uni-heidelberg.de
12 |
13 | source ~/.bashrc;
14 | conda activate sc_analysis;
15 | cd /beegfs/work/hd_wh241/MI_revisions;
16 |
17 | $CONDA_PREFIX/bin/Rscript ./analysis/1_snuc_QC_doublets_majorannotation/run_singleprocessing.R \
18 | --folder \
19 | --path "/beegfs/work/hd_wh241/Human_Acute_MI_Rafael/" \
20 | --out_path "/beegfs/work/hd_wh241/MI_revisions/kl_miatlas/processed_RNA/" \
21 | --out_fig_path "/beegfs/work/hd_wh241/MI_revisions/kl_miatlas/initial_qc/" \
22 | --outs_structure TRUE;
23 |
24 | $CONDA_PREFIX/bin/Rscript ./analysis/1_snuc_QC_doublets_majorannotation/plot_knownmarkers.R \
25 | --folder \
26 | --path "/beegfs/work/hd_wh241/MI_revisions/kl_miatlas/processed_RNA/" \
27 | --out_fig_path "/beegfs/work/hd_wh241/MI_revisions/kl_miatlas/initial_qc/";
28 |
29 | $CONDA_PREFIX/bin/Rscript ./analysis/2_snuc_integration_harmony/integrate_objects_kl.R \
30 | --path "/beegfs/work/hd_wh241/MI_revisions/kl_miatlas/processed_RNA/" \
31 | --out_file "/beegfs/work/hd_wh241/MI_revisions/kl_miatlas/kl_miatlas_integrated_data.rds" \
32 | --out_fig_file "/beegfs/work/hd_wh241/MI_revisions/kl_miatlas/kl_miatlas_integrated_data_qcint.pdf" \
33 | --def_assay "RNA" \
34 | --default_resolution 1;
35 |
36 | $CONDA_PREFIX/bin/Rscript ./analysis/1_snuc_QC_doublets_majorannotation/plot_knownmarkers.R \
37 | --id_label "opt_clust_integrated" \
38 | --path "/beegfs/work/hd_wh241/MI_revisions/kl_miatlas/kl_miatlas_integrated_data.rds" \
39 | --out_fig_path "/beegfs/work/hd_wh241/MI_revisions/kl_miatlas/";
--------------------------------------------------------------------------------
/st_snRNAseq/jobs/liana_Fib_Myeloid.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | #PBS -l nodes=1:ppn=16
3 | #PBS -l walltime=30:00:00
4 | #PBS -l mem=150gb
5 | #PBS -S /bin/bash
6 | #PBS -N lianafibmyeloid
7 | #PBS -o /beegfs/work/hd_wh241/MI_revisions/analysis/jobs/liana_Fib_Myeloid.out
8 | #PBS -e /beegfs/work/hd_wh241/MI_revisions/analysis/jobs/liana_Fib_Myeloid.err
9 | #PBS -q smp
10 | #PBS -m bea
11 | #PBS -M roramirezf@uni-heidelberg.de
12 |
13 | source ~/.bashrc;
14 | conda activate liana;
15 | cd /beegfs/work/hd_wh241/MI_revisions;
16 |
17 | $CONDA_PREFIX/bin/Rscript ./analysis/14_cellcomms/run_liana.R \
18 | --data_path "/beegfs/work/hd_wh241/MI_revisions/processed_snrnaseq/cell_states/integrated_rnasamples_ann_wstates.rds" \
19 | --cell_class "Fib,Myeloid" \
20 | --out_file "/beegfs/work/hd_wh241/MI_revisions/results/cell_comms/liana_Fib_Myeloid.rds";
--------------------------------------------------------------------------------
/st_snRNAseq/jobs/liana_cm.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | #PBS -l nodes=1:ppn=16
3 | #PBS -l walltime=30:00:00
4 | #PBS -l mem=150gb
5 | #PBS -S /bin/bash
6 | #PBS -N lianacm
7 | #PBS -o /beegfs/work/hd_wh241/MI_revisions/analysis/jobs/liana_cm.out
8 | #PBS -e /beegfs/work/hd_wh241/MI_revisions/analysis/jobs/liana_cm.err
9 | #PBS -q smp
10 | #PBS -m bea
11 | #PBS -M roramirezf@uni-heidelberg.de
12 |
13 | source ~/.bashrc;
14 | conda activate liana;
15 | cd /beegfs/work/hd_wh241/MI_revisions;
16 |
17 | $CONDA_PREFIX/bin/Rscript ./analysis/14_cellcomms/run_liana_adv.R \
18 | --data_path "/beegfs/work/hd_wh241/MI_revisions/processed_snrnaseq/cell_states/integrated_rnasamples_ann_wstates.rds" \
19 | --cell_type_list "Myeloid,vSMCs,Endo,Fib,Adipo" \
20 | --cell_state_list "CM" \
21 | --out_file "/beegfs/work/hd_wh241/MI_revisions/results/cell_comms/liana_CM.rds";
--------------------------------------------------------------------------------
/st_snRNAseq/jobs/liana_endo.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | #PBS -l nodes=1:ppn=16
3 | #PBS -l walltime=30:00:00
4 | #PBS -l mem=150gb
5 | #PBS -S /bin/bash
6 | #PBS -N visium_mrkr_estimation
7 | #PBS -o /beegfs/work/hd_wh241/MI_revisions/analysis/jobs/liana_endo.out
8 | #PBS -e /beegfs/work/hd_wh241/MI_revisions/analysis/jobs/liana_endo.err
9 | #PBS -q smp
10 | #PBS -m bea
11 | #PBS -M roramirezf@uni-heidelberg.de
12 |
13 | source ~/.bashrc;
14 | conda activate liana;
15 | cd /beegfs/work/hd_wh241/MI_revisions;
16 |
17 | $CONDA_PREFIX/bin/Rscript ./analysis/14_cellcomms/run_liana_adv.R \
18 | --data_path "/beegfs/work/hd_wh241/MI_revisions/processed_snrnaseq/cell_states/integrated_rnasamples_ann_wstates.rds" \
19 | --cell_type_list "CM,vSMCs,Fib,PC" \
20 | --cell_state_list "Endo" \
21 | --out_file "/beegfs/work/hd_wh241/MI_revisions/results/cell_comms/liana_Endo.rds";
--------------------------------------------------------------------------------
/st_snRNAseq/jobs/liana_endo_simple.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | #PBS -l nodes=1:ppn=16
3 | #PBS -l walltime=30:00:00
4 | #PBS -l mem=150gb
5 | #PBS -S /bin/bash
6 | #PBS -N lianapc
7 | #PBS -o /beegfs/work/hd_wh241/MI_revisions/analysis/jobs/liana_endo_simple.out
8 | #PBS -e /beegfs/work/hd_wh241/MI_revisions/analysis/jobs/liana_endo_simple.err
9 | #PBS -q smp
10 | #PBS -m bea
11 | #PBS -M roramirezf@uni-heidelberg.de
12 |
13 | source ~/.bashrc;
14 | conda activate liana;
15 | cd /beegfs/work/hd_wh241/MI_revisions;
16 |
17 | $CONDA_PREFIX/bin/Rscript ./analysis/14_cellcomms/run_liana.R \
18 | --data_path "/beegfs/work/hd_wh241/MI_revisions/processed_snrnaseq/cell_states/integrated_rnasamples_ann_wstates.rds" \
19 | --cell_class "CM,Fib,Endo" \
20 | --out_file "/beegfs/work/hd_wh241/MI_revisions/results/cell_comms/liana_endo_simple.rds";
21 |
--------------------------------------------------------------------------------
/st_snRNAseq/jobs/liana_pc.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | #PBS -l nodes=1:ppn=16
3 | #PBS -l walltime=30:00:00
4 | #PBS -l mem=150gb
5 | #PBS -S /bin/bash
6 | #PBS -N lianapc
7 | #PBS -o /beegfs/work/hd_wh241/MI_revisions/analysis/jobs/liana_pc.out
8 | #PBS -e /beegfs/work/hd_wh241/MI_revisions/analysis/jobs/liana_pc.err
9 | #PBS -q smp
10 | #PBS -m bea
11 | #PBS -M roramirezf@uni-heidelberg.de
12 |
13 | source ~/.bashrc;
14 | conda activate liana;
15 | cd /beegfs/work/hd_wh241/MI_revisions;
16 |
17 | $CONDA_PREFIX/bin/Rscript ./analysis/14_cellcomms/run_liana_adv.R \
18 | --data_path "/beegfs/work/hd_wh241/MI_revisions/processed_snrnaseq/cell_states/integrated_rnasamples_ann_wstates.rds" \
19 | --cell_type_list "CM,vSMCs,Endo,Fib" \
20 | --cell_state_list "PC" \
21 | --out_file "/beegfs/work/hd_wh241/MI_revisions/results/cell_comms/liana_PC.rds";
--------------------------------------------------------------------------------
/st_snRNAseq/jobs/liana_pc_simple.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | #PBS -l nodes=1:ppn=16
3 | #PBS -l walltime=30:00:00
4 | #PBS -l mem=150gb
5 | #PBS -S /bin/bash
6 | #PBS -N lianapc
7 | #PBS -o /beegfs/work/hd_wh241/MI_revisions/analysis/jobs/liana_pc_simple.out
8 | #PBS -e /beegfs/work/hd_wh241/MI_revisions/analysis/jobs/liana_pc_simple.err
9 | #PBS -q smp
10 | #PBS -m bea
11 | #PBS -M roramirezf@uni-heidelberg.de
12 |
13 | source ~/.bashrc;
14 | conda activate liana;
15 | cd /beegfs/work/hd_wh241/MI_revisions;
16 |
17 |
18 | $CONDA_PREFIX/bin/Rscript ./analysis/14_cellcomms/run_liana.R \
19 | --data_path "/beegfs/work/hd_wh241/MI_revisions/processed_snrnaseq/cell_states/integrated_rnasamples_ann_wstates.rds" \
20 | --cell_class "CM,vSMCs,Endo,Fib,PC" \
21 | --out_file "/beegfs/work/hd_wh241/MI_revisions/results/cell_comms/liana_PC_simple.rds";
22 |
--------------------------------------------------------------------------------
/st_snRNAseq/jobs/make_hca_h5admirror.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | #PBS -l nodes=1:ppn=8
3 | #PBS -l walltime=02:00:00
4 | #PBS -l mem=64gb
5 | #PBS -S /bin/bash
6 | #PBS -N h5admirror
7 | #PBS -o /beegfs/work/hd_wh241/MI_revisions/analysis/jobs/make_hca_h5admirror.out
8 | #PBS -e /beegfs/work/hd_wh241/MI_revisions/analysis/jobs/make_hca_h5admirror.err
9 | #PBS -q short
10 | #PBS -m bea
11 | #PBS -M roramirezf@uni-heidelberg.de
12 |
13 | source ~/.bashrc;
14 | conda activate sc_analysis;
15 | cd /beegfs/work/hd_wh241/MI_revisions;
16 |
17 | $CONDA_PREFIX/bin/Rscript ./analysis/utils/h5ad_mirrors.R \
18 | --scell_data "/beegfs/work/hd_wh241/MI_revisions/ext_data/hca_seurat.rds" \
19 | --out_file "/beegfs/work/hd_wh241/MI_revisions/ext_data/hca_seurat.h5ad";
--------------------------------------------------------------------------------
/st_snRNAseq/jobs/make_hca_objs.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | #PBS -l nodes=1:ppn=8
3 | #PBS -l walltime=02:00:00
4 | #PBS -l mem=64gb
5 | #PBS -S /bin/bash
6 | #PBS -N hcafiltering
7 | #PBS -o /beegfs/work/hd_wh241/MI_revisions/analysis/jobs/make_hca_objs.out
8 | #PBS -e /beegfs/work/hd_wh241/MI_revisions/analysis/jobs/make_hca_objs.err
9 | #PBS -q short
10 | #PBS -m bea
11 | #PBS -M roramirezf@uni-heidelberg.de
12 |
13 | source ~/.bashrc;
14 | conda activate sc_analysis;
15 | cd /beegfs/work/hd_wh241/MI_revisions;
16 |
17 | $CONDA_PREFIX/bin/Rscript ./analysis/mini_tasks/make_hca_objs.R;
--------------------------------------------------------------------------------
/st_snRNAseq/jobs/make_snrna_h5admirror.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | #PBS -l nodes=1:ppn=8
3 | #PBS -l walltime=03:00:00
4 | #PBS -l mem=150gb
5 | #PBS -S /bin/bash
6 | #PBS -N h5admirror
7 | #PBS -o /beegfs/work/hd_wh241/MI_revisions/analysis/jobs/make_snrna_h5admirror.out
8 | #PBS -e /beegfs/work/hd_wh241/MI_revisions/analysis/jobs/make_snrna_h5admirror.err
9 | #PBS -q smp
10 | #PBS -m bea
11 | #PBS -M roramirezf@uni-heidelberg.de
12 |
13 | source ~/.bashrc;
14 | conda activate sc_analysis;
15 | cd /beegfs/work/hd_wh241/MI_revisions;
16 |
17 | $CONDA_PREFIX/bin/Rscript ./analysis/utils/h5ad_mirrors.R \
18 | --scell_data "/beegfs/work/hd_wh241/MI_revisions/processed_snrnaseq/integration/integrated_rnasamples_ann.rds" \
19 | --out_file "/beegfs/work/hd_wh241/MI_revisions/processed_snrnaseq/integration/integrated_rnasamples_ann.h5ad";
--------------------------------------------------------------------------------
/st_snRNAseq/jobs/make_snrna_h5admirror_raw.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | #PBS -l nodes=1:ppn=8
3 | #PBS -l walltime=03:00:00
4 | #PBS -l mem=150gb
5 | #PBS -S /bin/bash
6 | #PBS -N h5admirror
7 | #PBS -o /beegfs/work/hd_wh241/MI_revisions/analysis/jobs/make_snrna_h5admirror_raw.out
8 | #PBS -e /beegfs/work/hd_wh241/MI_revisions/analysis/jobs/make_snrna_h5admirror_raw.err
9 | #PBS -q smp
10 | #PBS -m bea
11 | #PBS -M roramirezf@uni-heidelberg.de
12 |
13 | source ~/.bashrc;
14 | conda activate sc_analysis;
15 | cd /beegfs/work/hd_wh241/MI_revisions;
16 |
17 | $CONDA_PREFIX/bin/Rscript ./analysis/utils/h5ad_mirrors.R \
18 | --scell_data "/beegfs/work/hd_wh241/MI_revisions/processed_snrnaseq/integration/integrated_rnasamples.rds" \
19 | --out_file "/beegfs/work/hd_wh241/MI_revisions/processed_snrnaseq/integration/integrated_rnasamples.h5ad";
--------------------------------------------------------------------------------
/st_snRNAseq/jobs/make_snrna_scemirror.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | #PBS -l nodes=1:ppn=8
3 | #PBS -l walltime=02:00:00
4 | #PBS -l mem=130gb
5 | #PBS -S /bin/bash
6 | #PBS -N scemirror
7 | #PBS -o /beegfs/work/hd_wh241/MI_revisions/analysis/jobs/make_snrna_scemirror.out
8 | #PBS -e /beegfs/work/hd_wh241/MI_revisions/analysis/jobs/make_snrna_scemirror.err
9 | #PBS -q smp
10 | #PBS -m bea
11 | #PBS -M roramirezf@uni-heidelberg.de
12 |
13 | source ~/.bashrc;
14 | conda activate sc_analysis;
15 | cd /beegfs/work/hd_wh241/MI_revisions;
16 |
17 | $CONDA_PREFIX/bin/Rscript ./analysis/utils/sce_mirrors.R \
18 | --seurat_file "/beegfs/work/hd_wh241/MI_revisions/processed_snrnaseq/integration/integrated_rnasamples_ann.rds" \
19 | --sce_folder "/beegfs/work/hd_wh241/MI_revisions/processed_snrnaseq/integration/integrated_rnasamples_ann_sce" \
20 | --assay "RNA" \
21 | --reduction "umap_harmony";
--------------------------------------------------------------------------------
/st_snRNAseq/jobs/make_snrna_scemirror_raw.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | #PBS -l nodes=1:ppn=8
3 | #PBS -l walltime=02:00:00
4 | #PBS -l mem=130gb
5 | #PBS -S /bin/bash
6 | #PBS -N scemirror
7 | #PBS -o /beegfs/work/hd_wh241/MI_revisions/analysis/jobs/make_snrna_scemirror.out
8 | #PBS -e /beegfs/work/hd_wh241/MI_revisions/analysis/jobs/make_snrna_scemirror.err
9 | #PBS -q smp
10 | #PBS -m bea
11 | #PBS -M roramirezf@uni-heidelberg.de
12 |
13 | source ~/.bashrc;
14 | conda activate sc_analysis;
15 | cd /beegfs/work/hd_wh241/MI_revisions;
16 |
17 | $CONDA_PREFIX/bin/Rscript ./analysis/utils/sce_mirrors.R \
18 | --seurat_file "/beegfs/work/hd_wh241/MI_revisions/processed_snrnaseq/integration/integrated_rnasamples.rds" \
19 | --sce_folder "/beegfs/work/hd_wh241/MI_revisions/processed_snrnaseq/integration/integrated_rnasamples_sce" \
20 | --assay "RNA" \
21 | --reduction "umap_harmony";
--------------------------------------------------------------------------------
/st_snRNAseq/jobs/make_visium_scemirror.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | #PBS -l nodes=1:ppn=8
3 | #PBS -l walltime=02:00:00
4 | #PBS -l mem=130gb
5 | #PBS -S /bin/bash
6 | #PBS -N scemirror
7 | #PBS -o /beegfs/work/hd_wh241/MI_revisions/analysis/jobs/make_visium_scemirror.out
8 | #PBS -e /beegfs/work/hd_wh241/MI_revisions/analysis/jobs/make_visium_scemirror.err
9 | #PBS -q smp
10 | #PBS -m bea
11 | #PBS -M roramirezf@uni-heidelberg.de
12 |
13 | source ~/.bashrc;
14 | conda activate sc_analysis;
15 | cd /beegfs/work/hd_wh241/MI_revisions;
16 |
17 | $CONDA_PREFIX/bin/Rscript ./analysis/utils/sce_mirrors.R \
18 | --seurat_file "/beegfs/work/hd_wh241/MI_revisions/processed_visium/integration/integrated_slides.rds" \
19 | --sce_folder "/beegfs/work/hd_wh241/MI_revisions/processed_visium/integration/integrated_slides_sce" \
20 | --assay "Spatial" \
21 | --reduction "umap_harmony";
--------------------------------------------------------------------------------
/st_snRNAseq/jobs/plot_mrks_niches.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | #PBS -l nodes=1:ppn=4
3 | #PBS -l walltime=04:00:00
4 | #PBS -l mem=64gb
5 | #PBS -S /bin/bash
6 | #PBS -N spatial_pseudobulk
7 | #PBS -o /beegfs/work/hd_wh241/MI_revisions/analysis/jobs/plot_mrks_niches.out
8 | #PBS -e /beegfs/work/hd_wh241/MI_revisions/analysis/jobs/plot_mrks_niches.err
9 | #PBS -q short
10 | #PBS -m bea
11 | #PBS -M roramirezf@uni-heidelberg.de
12 |
13 | source ~/.bashrc;
14 | conda activate sc_analysis;
15 | cd /beegfs/work/hd_wh241/MI_revisions;
16 |
17 | $CONDA_PREFIX/bin/Rscript ./analysis/1_snuc_QC_doublets_majorannotation/plot_knownmarkers.R \
18 | --path "/beegfs/work/hd_wh241/MI_revisions/processed_visium/integration/integrated_slides.rds" \
19 | --id_label "opt_clust_integrated" \
20 | --out_fig_path "/beegfs/work/hd_wh241/MI_revisions/processed_visium/integration/" \
21 | --used_assay "Spatial";
--------------------------------------------------------------------------------
/st_snRNAseq/jobs/regress_bckground_fibro.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | #PBS -l nodes=1:ppn=8
3 | #PBS -l walltime=08:00:00
4 | #PBS -l mem=150gb
5 | #PBS -S /bin/bash
6 | #PBS -N cell_states
7 | #PBS -o /beegfs/work/hd_wh241/MI_revisions/analysis/jobs/regress_bckground_Fib.out
8 | #PBS -e /beegfs/work/hd_wh241/MI_revisions/analysis/jobs/regress_bckground_Fib.err
9 | #PBS -q smp
10 | #PBS -m bea
11 | #PBS -M roramirezf@uni-heidelberg.de
12 |
13 | source ~/.bashrc;
14 | conda activate sc_analysis;
15 | cd /beegfs/work/hd_wh241/MI_revisions;
16 |
17 | mkdir ./results/ct_data_bckground/Fib;
18 |
19 | #$CONDA_PREFIX/bin/Rscript ./analysis/10_cellstates/regress_bckground.R \
20 | # --data_path "/beegfs/work/hd_wh241/MI_revisions/results/ct_data/Fib/Fib_states.rds" \
21 | # --obj_out "/beegfs/work/hd_wh241/MI_revisions/results/ct_data_bckground/Fib/Fib_states.rds";
22 |
23 | $CONDA_PREFIX/bin/Rscript ./analysis/utils/h5ad_mirrors.R \
24 | --scell_data "/beegfs/work/hd_wh241/MI_revisions/results/ct_data_bckground/Fib/Fib_states.rds" \
25 | --out_file "/beegfs/work/hd_wh241/MI_revisions/results/ct_data_bckground/Fib/Fib_states.h5ad";
26 |
27 | $CONDA_PREFIX/bin/Rscript ./analysis/utils/sce_mirrors.R \
28 | --seurat_file "/beegfs/work/hd_wh241/MI_revisions/results/ct_data_bckground/Fib/Fib_states.rds" \
29 | --sce_folder "/beegfs/work/hd_wh241/MI_revisions/results/ct_data_bckground/Fib/Fib_states_sce" \
30 | --assay "RNA" \
31 | --reduction "umap";
32 |
33 | $CONDA_PREFIX/bin/Rscript ./analysis/6_atlas_comparison/get_pseudobulk_profiles.R \
34 | --path "/beegfs/work/hd_wh241/MI_revisions/results/ct_data_bckground/Fib/Fib_states.rds" \
35 | --vars "orig.ident,opt_state" \
36 | --collapsed "yes" \
37 | --out_path "/beegfs/work/hd_wh241/MI_revisions/results/ct_data_bckground/Fib/ps_Fib_states.rds" \
38 | --def_assay "RNA";
--------------------------------------------------------------------------------
/st_snRNAseq/jobs/run_snrnaseq_integration.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | #PBS -l nodes=1:ppn=4
3 | #PBS -l walltime=04:00:00
4 | #PBS -l mem=200gb
5 | #PBS -S /bin/bash
6 | #PBS -N snrnaseq_int
7 | #PBS -o /beegfs/work/hd_wh241/MI_revisions/analysis/jobs/run_snrnaseq_integration.out
8 | #PBS -e /beegfs/work/hd_wh241/MI_revisions/analysis/jobs/run_snrnaseq_integration.err
9 | #PBS -q smp
10 | #PBS -m bea
11 | #PBS -M roramirezf@uni-heidelberg.de
12 |
13 | source ~/.bashrc;
14 | conda activate sc_analysis;
15 | cd /beegfs/work/hd_wh241/MI_revisions;
16 |
17 | $CONDA_PREFIX/bin/Rscript ./analysis/2_snuc_integration_harmony/integrate_objects.R \
18 | --path "/beegfs/work/hd_wh241/MI_revisions/processed_snrnaseq/objects/" \
19 | --out_file "/beegfs/work/hd_wh241/MI_revisions/processed_snrnaseq/integration/integrated_rnasamples.rds" \
20 | --out_fig_file "/beegfs/work/hd_wh241/MI_revisions/processed_snrnaseq/integration/integrated_rnasamples.pdf" \
21 | --def_assay "RNA" \
22 | --batch_file "/beegfs/work/hd_wh241/MI_revisions/markers/snrna_batch_ann.csv" \
23 | --default_resolution 1;
--------------------------------------------------------------------------------
/st_snRNAseq/jobs/run_snrnaseq_mrkrplt.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | #PBS -l nodes=1:ppn=4
3 | #PBS -l walltime=02:00:00
4 | #PBS -l mem=150gb
5 | #PBS -S /bin/bash
6 | #PBS -N snrnaseq_mrkrs
7 | #PBS -o /beegfs/work/hd_wh241/MI_revisions/analysis/jobs/run_snrnaseq_mrkrplt.out
8 | #PBS -e /beegfs/work/hd_wh241/MI_revisions/analysis/jobs/run_snrnaseq_mrkrplt.err
9 | #PBS -q smp
10 | #PBS -m bea
11 | #PBS -M roramirezf@uni-heidelberg.de
12 |
13 | source ~/.bashrc;
14 | conda activate sc_analysis;
15 | cd /beegfs/work/hd_wh241/MI_revisions;
16 |
17 | $CONDA_PREFIX/bin/Rscript ./analysis/1_snuc_QC_doublets_majorannotation/plot_knownmarkers.R \
18 | --downsampling \
19 | --used_assay "RNA" \
20 | --id_label "opt_clust_integrated" \
21 | --path "/beegfs/work/hd_wh241/MI_revisions/processed_snrnaseq/integration/integrated_rnasamples.rds" \
22 | --out_fig_path "/beegfs/work/hd_wh241/MI_revisions/processed_snrnaseq/integration/";
--------------------------------------------------------------------------------
/st_snRNAseq/jobs/run_spark.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | #PBS -l nodes=1:ppn=6
3 | #PBS -l walltime=03:00:00
4 | #PBS -l mem=32gb
5 | #PBS -S /bin/bash
6 | #PBS -N spatial_variability
7 | #PBS -o /beegfs/work/hd_wh241/MI_revisions/analysis/jobs/run_spark.out
8 | #PBS -e /beegfs/work/hd_wh241/MI_revisions/analysis/jobs/run_spark.err
9 | #PBS -q short
10 | #PBS -m bea
11 | #PBS -M roramirezf@uni-heidelberg.de
12 |
13 | source ~/.bashrc;
14 | conda activate sc_analysis;
15 | cd /beegfs/work/hd_wh241/MI_revisions;
16 |
17 | $CONDA_PREFIX/bin/Rscript ./analysis/1.1_spatial_QC_reading/run_spark.R \
18 | --path "/beegfs/work/hd_wh241/MI_revisions/processed_visium/objects/" \
19 | --out_path "/beegfs/work/hd_wh241/MI_revisions/results/spark/";
--------------------------------------------------------------------------------
/st_snRNAseq/jobs/run_spark.txt:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | #PBS -l nodes=1:ppn=4
3 | #PBS -l walltime=08:00:00
4 | #PBS -l mem=64gb
5 | #PBS -S /bin/bash
6 | #PBS -N spatial_proc
7 | #PBS -o /beegfs/work/hd_wh241/MI_revisions/analysis/jobs/run_spatial_singleprocessing.out
8 | #PBS -e /beegfs/work/hd_wh241/MI_revisions/analysis/jobs/run_spatial_singleprocessing.err
9 | #PBS -q short
10 | #PBS -m bea
11 | #PBS -M roramirezf@uni-heidelberg.de
12 |
13 | source ~/.bashrc;
14 | conda activate sc_analysis;
15 | cd /beegfs/work/hd_wh241/MI_revisions;
16 |
17 | $CONDA_PREFIX/bin/Rscript ./analysis/1.1_spatial_QC_reading/run_singleprocessing_spatial.R \
18 | --folder \
19 | --path "/beegfs/work/hd_wh241/MI_revisions/visium_data/" \
20 | --out_path "/beegfs/work/hd_wh241/MI_revisions/processed_visium/objects/" \
21 | --out_fig_path "/beegfs/work/hd_wh241/MI_revisions/processed_visium/initial_qc/" \
22 | --force_filter;
--------------------------------------------------------------------------------
/st_snRNAseq/jobs/run_spatial_integration.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | #PBS -l nodes=1:ppn=4
3 | #PBS -l walltime=08:00:00
4 | #PBS -l mem=200gb
5 | #PBS -S /bin/bash
6 | #PBS -N spatial_proc
7 | #PBS -o /beegfs/work/hd_wh241/MI_revisions/analysis/jobs/run_spatial_integration.out
8 | #PBS -e /beegfs/work/hd_wh241/MI_revisions/analysis/jobs/run_spatial_integration.err
9 | #PBS -q smp
10 | #PBS -m bea
11 | #PBS -M roramirezf@uni-heidelberg.de
12 |
13 | source ~/.bashrc;
14 | conda activate sc_analysis;
15 | cd /beegfs/work/hd_wh241/MI_revisions;
16 |
17 | $CONDA_PREFIX/bin/Rscript ./analysis/2_snuc_integration_harmony/integrate_objects.R \
18 | --path "/beegfs/work/hd_wh241/MI_revisions/processed_visium/objects/" \
19 | --out_file "/beegfs/work/hd_wh241/MI_revisions/processed_visium/integration/integrated_slides.rds" \
20 | --out_fig_file "/beegfs/work/hd_wh241/MI_revisions/processed_visium/integration/integrated_slides_qcint.pdf" \
21 | --def_assay "Spatial" \
22 | --batch_file "/beegfs/work/hd_wh241/MI_revisions/markers/visium_batch_ann.csv" \
23 | --default_resolution 0.5;
24 |
25 | $CONDA_PREFIX/bin/Rscript ./analysis/6_atlas_comparison/get_pseudobulk_profiles.R \
26 | --path "/beegfs/work/hd_wh241/MI_revisions/processed_visium/integration/integrated_slides.rds" \
27 | --vars "orig.ident" \
28 | --out_path "/beegfs/work/hd_wh241/MI_revisions/processed_visium/integration/ps_integrated_slides.rds" \
29 | --def_assay "Spatial";
30 |
31 | $CONDA_PREFIX/bin/Rscript ./analysis/6_atlas_comparison/get_pseudobulk_profiles.R \
32 | --path "/beegfs/work/hd_wh241/MI_revisions/processed_visium/integration/integrated_slides.rds" \
33 | --vars "orig.ident,opt_clust_integrated" \
34 | --out_path "/beegfs/work/hd_wh241/MI_revisions/processed_visium/integration/ps_integrated_slides_niches.rds" \
35 | --collapsed "yes" \
36 | --def_assay "Spatial";
37 |
38 | $CONDA_PREFIX/bin/Rscript ./analysis/utils/sce_mirrors.R \
39 | --seurat_file "/beegfs/work/hd_wh241/MI_revisions/processed_visium/integration/integrated_slides.rds" \
40 | --sce_folder "/beegfs/work/hd_wh241/MI_revisions/processed_visium/integration/integrated_slides_sce" \
41 | --assay "Spatial" \
42 | --reduction "umap_harmony";
--------------------------------------------------------------------------------
/st_snRNAseq/jobs/run_spatial_pseudobulk.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | #PBS -l nodes=1:ppn=4
3 | #PBS -l walltime=04:00:00
4 | #PBS -l mem=64gb
5 | #PBS -S /bin/bash
6 | #PBS -N spatial_pseudobulk
7 | #PBS -o /beegfs/work/hd_wh241/MI_revisions/analysis/jobs/run_spatial_pseudobulk.out
8 | #PBS -e /beegfs/work/hd_wh241/MI_revisions/analysis/jobs/run_spatial_pseudobulk.err
9 | #PBS -q short
10 | #PBS -m bea
11 | #PBS -M roramirezf@uni-heidelberg.de
12 |
13 | source ~/.bashrc;
14 | conda activate sc_analysis;
15 | cd /beegfs/work/hd_wh241/MI_revisions;
16 |
17 | $CONDA_PREFIX/bin/Rscript ./analysis/6_atlas_comparison/get_pseudobulk_profiles.R \
18 | --path "/beegfs/work/hd_wh241/MI_revisions/processed_visium/integration/integrated_slides.rds" \
19 | --vars "orig.ident" \
20 | --out_path "/beegfs/work/hd_wh241/MI_revisions/processed_visium/integration/ps_integrated_slides.rds" \
21 | --def_assay "Spatial";
22 |
23 | $CONDA_PREFIX/bin/Rscript ./analysis/6_atlas_comparison/get_pseudobulk_profiles.R \
24 | --path "/beegfs/work/hd_wh241/MI_revisions/processed_visium/integration/integrated_slides.rds" \
25 | --vars "orig.ident,opt_clust_integrated" \
26 | --out_path "/beegfs/work/hd_wh241/MI_revisions/processed_visium/integration/ps_integrated_slides_niches.rds" \
27 | --collapsed "yes" \
28 | --def_assay "Spatial";
--------------------------------------------------------------------------------
/st_snRNAseq/jobs/run_spatial_singleprocessing.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | #PBS -l nodes=1:ppn=4
3 | #PBS -l walltime=08:00:00
4 | #PBS -l mem=64gb
5 | #PBS -S /bin/bash
6 | #PBS -N spatial_proc
7 | #PBS -o /beegfs/work/hd_wh241/MI_revisions/analysis/jobs/run_spatial_singleprocessing.out
8 | #PBS -e /beegfs/work/hd_wh241/MI_revisions/analysis/jobs/run_spatial_singleprocessing.err
9 | #PBS -q short
10 | #PBS -m bea
11 | #PBS -M roramirezf@uni-heidelberg.de
12 |
13 | source ~/.bashrc;
14 | conda activate sc_analysis;
15 | cd /beegfs/work/hd_wh241/MI_revisions;
16 |
17 | $CONDA_PREFIX/bin/Rscript ./analysis/1.1_spatial_QC_reading/run_singleprocessing_spatial.R \
18 | --folder \
19 | --path "/beegfs/work/hd_wh241/MI_revisions/visium_data/" \
20 | --out_path "/beegfs/work/hd_wh241/MI_revisions/processed_visium/objects/" \
21 | --out_fig_path "/beegfs/work/hd_wh241/MI_revisions/processed_visium/initial_qc/" \
22 | --force_filter;
--------------------------------------------------------------------------------
/st_snRNAseq/jobs/run_spatial_singleprocessing_unfiltered.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | #PBS -l nodes=1:ppn=4
3 | #PBS -l walltime=08:00:00
4 | #PBS -l mem=150gb
5 | #PBS -S /bin/bash
6 | #PBS -N spatial_proc
7 | #PBS -o /beegfs/work/hd_wh241/MI_revisions/analysis/jobs/run_spatial_singleprocessing_unfiltered.out
8 | #PBS -e /beegfs/work/hd_wh241/MI_revisions/analysis/jobs/run_spatial_singleprocessing_unfiltered.err
9 | #PBS -q smp
10 | #PBS -m bea
11 | #PBS -M roramirezf@uni-heidelberg.de
12 |
13 | source ~/.bashrc;
14 | conda activate sc_analysis;
15 | cd /beegfs/work/hd_wh241/MI_revisions;
16 |
17 | $CONDA_PREFIX/bin/Rscript ./analysis/1.1_spatial_QC_reading/run_singleprocessing_spatial.R \
18 | --folder \
19 | --path "/beegfs/work/hd_wh241/MI_revisions/visium_data/" \
20 | --out_path "/beegfs/work/hd_wh241/MI_revisions/processed_visium_unfiltered/objects/" \
21 | --out_fig_path "/beegfs/work/hd_wh241/MI_revisions/processed_visium_unfiltered/initial_qc/" \
22 | --force_filter FALSE;
--------------------------------------------------------------------------------
/st_snRNAseq/jobs/snatlas_run_pipeline.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | #PBS -l nodes=1:ppn=4
3 | #PBS -l walltime=05:00:00
4 | #PBS -l mem=64gb
5 | #PBS -S /bin/bash
6 | #PBS -N single_snuc_proc
7 | #PBS -o /beegfs/work/hd_wh241/MI_revisions/analysis/jobs/snatlas_run_pipeline.out
8 | #PBS -e /beegfs/work/hd_wh241/MI_revisions/analysis/jobs/snatlas_run_pipeline.err
9 | #PBS -q short
10 | #PBS -m bea
11 | #PBS -M roramirezf@uni-heidelberg.de
12 |
13 | source ~/.bashrc;
14 | conda activate sc_analysis;
15 | cd /beegfs/work/hd_wh241/MI_revisions;
16 |
17 | $CONDA_PREFIX/bin/Rscript ./analysis/1_snuc_QC_doublets_majorannotation/run_singleprocessing.R \
18 | --folder \
19 | --path "/beegfs/work/hd_wh241/MI_revisions/snrnaseq_data/" \
20 | --out_path "/beegfs/work/hd_wh241/MI_revisions/processed_snrnaseq/objects/" \
21 | --out_fig_path "/beegfs/work/hd_wh241/MI_revisions/processed_snrnaseq/initial_qc/" \
22 | --outs_structure TRUE;
23 |
24 | $CONDA_PREFIX/bin/Rscript ./analysis/1_snuc_QC_doublets_majorannotation/plot_knownmarkers.R \
25 | --folder \
26 | --path "/beegfs/work/hd_wh241/MI_revisions/processed_snrnaseq/objects/" \
27 | --out_fig_path "/beegfs/work/hd_wh241/MI_revisions/processed_snrnaseq/initial_qc/";
--------------------------------------------------------------------------------
/st_snRNAseq/jobs/snatlas_run_pipeline_bckground.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | #PBS -l nodes=1:ppn=4
3 | #PBS -l walltime=10:00:00
4 | #PBS -l mem=200gb
5 | #PBS -S /bin/bash
6 | #PBS -N single_snuc_proc
7 | #PBS -o /beegfs/work/hd_wh241/MI_revisions/analysis/jobs/snatlas_run_pipeline_bckgrnd.out
8 | #PBS -e /beegfs/work/hd_wh241/MI_revisions/analysis/jobs/snatlas_run_pipeline_bckgrnd.err
9 | #PBS -q smp
10 | #PBS -m bea
11 | #PBS -M roramirezf@uni-heidelberg.de
12 |
13 | source ~/.bashrc;
14 | conda activate sc_analysis;
15 | cd /beegfs/work/hd_wh241/MI_revisions;
16 |
17 | $CONDA_PREFIX/bin/Rscript ./analysis/1_snuc_QC_doublets_majorannotation/run_singleprocessing_bckgrndcor.R \
18 | --folder \
19 | --path "/beegfs/work/hd_wh241/MI_revisions/snrnaseq_data/" \
20 | --out_path "/beegfs/work/hd_wh241/MI_revisions/processed_snrnaseq_bckgrnd/objects/" \
21 | --out_fig_path "/beegfs/work/hd_wh241/MI_revisions/processed_snrnaseq_bckgrnd/initial_qc/" \
22 | --outs_structure TRUE;
23 |
24 | $CONDA_PREFIX/bin/Rscript ./analysis/1_snuc_QC_doublets_majorannotation/plot_knownmarkers.R \
25 | --folder \
26 | --path "/beegfs/work/hd_wh241/MI_revisions/processed_snrnaseq_bckgrnd/objects/" \
27 | --out_fig_path "/beegfs/work/hd_wh241/MI_revisions/processed_snrnaseq_bckgrnd/initial_qc/";
28 |
29 | $CONDA_PREFIX/bin/Rscript ./analysis/2_snuc_integration_harmony/integrate_objects.R \
30 | --path "/beegfs/work/hd_wh241/MI_revisions/processed_snrnaseq_bckgrnd/objects/" \
31 | --out_file "/beegfs/work/hd_wh241/MI_revisions/processed_snrnaseq_bckgrnd/integration/integrated_rnasamples.rds" \
32 | --out_fig_file "/beegfs/work/hd_wh241/MI_revisions/processed_snrnaseq_bckgrnd/integration/integrated_rnasamples.pdf" \
33 | --def_assay "RNA" \
34 | --batch_file "/beegfs/work/hd_wh241/MI_revisions/markers/snrna_batch_ann.csv" \
35 | --default_resolution 1;
--------------------------------------------------------------------------------
/st_snRNAseq/jobs/subsample_atlas.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | #PBS -l nodes=1:ppn=8
3 | #PBS -l walltime=24:00:00
4 | #PBS -l mem=150gb
5 | #PBS -S /bin/bash
6 | #PBS -N subsample_atlas
7 | #PBS -o /beegfs/work/hd_wh241/MI_revisions/analysis/jobs/subsample_atlas.out
8 | #PBS -e /beegfs/work/hd_wh241/MI_revisions/analysis/jobs/subsample_atlas.err
9 | #PBS -q smp
10 | #PBS -m bea
11 | #PBS -M roramirezf@uni-heidelberg.de
12 |
13 | source ~/.bashrc;
14 | conda activate sc_analysis;
15 | cd /beegfs/work/hd_wh241/MI_revisions;
16 |
17 | $CONDA_PREFIX/bin/Rscript ./analysis/mini_tasks/make_atlas_subsamples.R;
18 |
--------------------------------------------------------------------------------
/st_snRNAseq/jobs/test_liana.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | #PBS -l nodes=1:ppn=16
3 | #PBS -l walltime=30:00:00
4 | #PBS -l mem=150gb
5 | #PBS -S /bin/bash
6 | #PBS -N visium_mrkr_estimation
7 | #PBS -o /beegfs/work/hd_wh241/MI_revisions/analysis/jobs/test_liana.out
8 | #PBS -e /beegfs/work/hd_wh241/MI_revisions/analysis/jobs/test_liana.err
9 | #PBS -q smp
10 | #PBS -m bea
11 | #PBS -M roramirezf@uni-heidelberg.de
12 |
13 | source ~/.bashrc;
14 | conda activate cell_comms;
15 | cd /beegfs/work/hd_wh241/MI_revisions;
16 |
17 | $CONDA_PREFIX/bin/Rscript ./analysis/mini_tasks/test_liana.R;
--------------------------------------------------------------------------------
/st_snRNAseq/utils/add_niche_info_v2.R:
--------------------------------------------------------------------------------
1 | # Copyright (c) [2021] [Ricardo O. Ramirez Flores]
2 | # roramirezf@uni-heidelberg.de
3 |
4 | #' Integrate niche annotations to individual slides for simplification
5 | #'
6 | #' Coming from the cell-type based niche definition
7 | #'
8 | #' visium_folder
9 | #' |
10 | #' -------samplename.rds
11 | #'
12 | #'
13 | #' annotation table from find_niches_ct
14 | #'
15 |
16 | library(Seurat)
17 | library(tidyverse)
18 |
19 | spot_annotation <- readRDS("./results/niche_mapping/ct_niches/niche_annotation_ct.rds") %>%
20 | dplyr::mutate(spot_id = map_chr(strsplit(row_id, "[..]"), ~.x[[3]]),
21 | orig.ident = map_chr(strsplit(row_id, "[..]"), ~.x[[1]])) %>%
22 | dplyr::select_at(c("orig.ident", "spot_id", "ct_niche")) %>%
23 | dplyr::rename("opt_clust_integrated_ct" = ct_niche)
24 |
25 | # Get visium slides --------------------------------
26 | visium_folder <- "./processed_visium/objects/"
27 | visium_files <- list.files(visium_folder, full.names = F)
28 | visium_samples <- gsub("[.]rds", "", visium_files)
29 |
30 | visium_df <- tibble(visium_file = paste0(visium_folder,
31 | visium_files),
32 | sample = visium_samples) %>%
33 | dplyr::filter(sample %in% pull(spot_annotation,
34 | orig.ident) %>% unique())
35 |
36 | # Add the niche information -------------------------
37 |
38 | add_niche_name <- function(visium_file, sample) {
39 |
40 | # read visium and table
41 | print(sample)
42 |
43 | visium_slide <- readRDS(visium_file)
44 |
45 | sample_meta <- spot_annotation %>%
46 | dplyr::filter(orig.ident == sample)
47 |
48 | if(ncol(visium_slide) == nrow(sample_meta)) {
49 |
50 | visium_meta <- visium_slide@meta.data %>%
51 | rownames_to_column("spot_id") %>%
52 | dplyr::select(spot_id, orig.ident) %>%
53 | mutate_at(c("spot_id"), as.character()) %>%
54 | left_join(sample_meta, by = "spot_id")
55 |
56 | # Here we overwrite
57 | visium_slide$opt_clust_integrated <- visium_meta$opt_clust_integrated_ct
58 |
59 | saveRDS(visium_slide, file = visium_file)
60 |
61 | } else{
62 |
63 | print("something went wrong with the mapping")
64 |
65 | }
66 | }
67 |
68 | pwalk(visium_df, add_niche_name)
69 |
--------------------------------------------------------------------------------
/st_snRNAseq/utils/c2l_to_R.R:
--------------------------------------------------------------------------------
1 | # Copyright (c) [2021] [Ricardo O. Ramirez Flores]
2 | # roramirezf@uni-heidelberg.de
3 |
4 | #' Copying cell2location models to simpler paths
5 | library(tidyverse)
6 | deconv_mats_folder <- "./results/deconvolution_models/location_models/density_tables/"
7 | deconv_rds_folder <- "./results/deconvolution_models/location_models/density_tables_rds/"
8 | mats_files <- list.files(deconv_mats_folder)
9 | mats_files <- mats_files[grepl("q05", mats_files)]
10 | rds_files <- paste0(map_chr(strsplit(mats_files,"_W"),
11 | ~ .x[1]),
12 | ".rds")
13 |
14 | walk2(mats_files, rds_files, function(mf, rf) {
15 | print(rf)
16 |
17 | prefix <- paste0(gsub("[.]rds", "",rf), "_")
18 |
19 | mat <- read.csv(paste0(deconv_mats_folder, mf),
20 | row.names = 1)
21 |
22 | rownames(mat) <- map_chr(strsplit(rownames(mat), prefix), ~ .x[2])
23 |
24 | colnames(mat) <- gsub("q05_spot_factors", "", colnames(mat))
25 |
26 | saveRDS(as.matrix(mat), file = paste0(deconv_rds_folder, rf))
27 | })
28 |
29 |
30 |
31 |
32 |
33 |
34 |
--------------------------------------------------------------------------------
/st_snRNAseq/utils/h5ad_mirrors.R:
--------------------------------------------------------------------------------
1 | # Copyright (c) [2021] [Ricardo O. Ramirez Flores]
2 | # roramirezf@uni-heidelberg.de
3 |
4 | #' In this script we transform data from scell objects to anndatas
5 |
6 | library(Seurat)
7 | library(zellkonverter)
8 | library(tidyverse)
9 | library(optparse)
10 |
11 | # Argument definition ---------------------------------------------------------------------------------
12 | option_list <- list(
13 | make_option(c("--scell_data"),
14 | action ="store",
15 | default = NULL,
16 | type = 'character',
17 | help = "scell data with states in a variable"),
18 | make_option(c("--out_file"),
19 | action= "store",
20 | default = NULL,
21 | type = 'character',
22 | help = "where to save the anndata object?")
23 |
24 | )
25 |
26 | # Parse the parameters ---------------------------------------------------------------------------------
27 | opt <- parse_args(OptionParser(option_list=option_list))
28 |
29 | cat("[INFO] Input parameters\n", file=stdout())
30 | for(user_input in names(opt)) {
31 | if(user_input=="help") next;
32 | cat(paste0("[INFO] ",user_input," => ",opt[[user_input]],"\n"),file = stdout())
33 | assign(user_input,opt[[user_input]])
34 | }
35 |
36 | scell_obj <- readRDS(scell_data)
37 | # Replace all dots with _
38 | colnames(scell_obj@meta.data) <- gsub("[.]", "_", colnames(scell_obj@meta.data))
39 | scell_obj <- as.SingleCellExperiment(scell_obj, assay = "RNA")
40 | writeH5AD(scell_obj, file = out_file)
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
--------------------------------------------------------------------------------
/st_snRNAseq/utils/loom_mirrors.R:
--------------------------------------------------------------------------------
1 | # Copyright (c) [2021] [Ricardo O. Ramirez Flores]
2 | # roramirezf@uni-heidelberg.de
3 |
4 | #' Convert from Seurat to anndata
5 | #'
6 | #'
7 |
8 | library(tidyverse)
9 | library(Seurat)
10 | library(loomR)
11 | library(optparse)
12 |
13 | # Argument definition ---------------------------------------------------------------------------------
14 | option_list <- list(
15 | make_option(c("--scell_data"),
16 | action ="store",
17 | default = NULL,
18 | type = 'character',
19 | help = "scell data with states in a variable"),
20 | make_option(c("--out_file"),
21 | action= "store",
22 | default = NULL,
23 | type = 'character',
24 | help = "where to save the anndata object?")
25 |
26 | )
27 |
28 | # Parse the parameters ---------------------------------------------------------------------------------
29 | opt <- parse_args(OptionParser(option_list=option_list))
30 |
31 | cat("[INFO] Input parameters\n", file=stdout())
32 | for(user_input in names(opt)) {
33 | if(user_input=="help") next;
34 | cat(paste0("[INFO] ",user_input," => ",opt[[user_input]],"\n"),file = stdout())
35 | assign(user_input,opt[[user_input]])
36 | }
37 |
38 | scell_obj <- readRDS(scell_data)
39 |
40 | DefaultAssay(scell_obj) <- "RNA"
41 |
42 | scell_obj_loom <- as.loom(scell_obj,
43 | filename = out_file,
44 | verbose = FALSE)
45 |
46 |
47 |
--------------------------------------------------------------------------------
/st_snRNAseq/utils/map_annotations.R:
--------------------------------------------------------------------------------
1 | library(Seurat)
2 | library(tidyverse)
3 |
4 | vars_to_transfer <- "States"
5 |
6 | data_A <- readRDS("./visium_results_manuscript/ct_data/fibro/fibroblasts_states.rds")
7 | data_B <- readRDS("./visium_results_manuscript/ct_data/fibro_snRNA.Rds")
8 |
9 | # To be sure we always use cell_ids and orig.ident
10 | meta_son <- data_B@meta.data %>%
11 | rownames_to_column("cell_id")
12 |
13 | meta_son <- meta_son[,c("cell_id","orig.ident",vars_to_transfer)]
14 | rm(data_B)
15 |
16 | meta_parent <- data_A@meta.data %>%
17 | rownames_to_column("cell_id") %>%
18 | left_join(meta_son, by = c("cell_id","orig.ident"))
19 |
20 | meta_parent[,vars_to_transfer] <- gsub("[()]","", meta_parent[,vars_to_transfer])
21 |
22 | data_A <- AddMetaData(object = data_A,
23 | meta_parent[,vars_to_transfer],
24 | col.name = vars_to_transfer)
25 |
26 | saveRDS(data_A, file = "./visium_results_manuscript/ct_data/fibroblasts_states.rds")
27 |
--------------------------------------------------------------------------------
/st_snRNAseq/utils/pca_utils.R:
--------------------------------------------------------------------------------
1 | # Copyright (c) [2021] [Ricardo O. Ramirez Flores]
2 | # roramirezf@uni-heidelberg.de
3 |
4 | #' Utilities for dimensionality reduction
5 |
6 |
7 | #' Get importances of specific PCs
8 | #' @param prcomp_obj: an object from a prcomp run
9 | #' @param pc: character, it is usually in the form "PC#"
10 | #' @param ntop: numeric. Number of top features to consider based in abs(value)
11 |
12 | get_pc_importances <- function(prcomp_obj, pc = "PC1", ntop = 20) {
13 |
14 | prcomp_obj$rotation %>%
15 | as.data.frame() %>%
16 | rownames_to_column("term") %>%
17 | pivot_longer(-term) %>%
18 | arrange(name, -abs(value)) %>%
19 | dplyr::filter(name == pc) %>%
20 | slice(1:ntop) %>%
21 | arrange(value)
22 | }
23 |
24 | #' Create a ggbarplot of importances
25 | #' @param pc_importances: an output object from get_pc_importances
26 | plot_pc_importances <- function(pc_importances) {
27 |
28 | pc_importances_order <- pc_importances %>%
29 | pull(term)
30 |
31 | ggplot(pc_importances,
32 | aes(x = factor(term, levels = pc_importances_order),
33 | y = value)) +
34 | geom_bar(stat = "identity") +
35 | theme(axis.text.x = element_text(angle = 90, hjust =1, vjust =0.5)) +
36 | xlab("") + ylab("Importance")
37 | }
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
--------------------------------------------------------------------------------
/st_snRNAseq/utils/sce_mirrors.R:
--------------------------------------------------------------------------------
1 | # Copyright (c) [2021] [Ricardo O. Ramirez Flores]
2 | # roramirezf@uni-heidelberg.de
3 |
4 | #' In this script we perform the transformation needed for the
5 | #' single cell objects to generate the shiny apps
6 | #' powered by iSEE
7 |
8 | library(optparse)
9 | library(Seurat)
10 | library(HDF5Array)
11 | library(scater)
12 |
13 | # Argument definition ---------------------------------------------------------------------------------
14 | option_list <- list(
15 | make_option(c("--seurat_file"),
16 | action ="store",
17 | default = NULL,
18 | type = 'character',
19 | help = "scell data with states in a variable"),
20 | make_option(c("--sce_folder"),
21 | action= "store",
22 | default = NULL,
23 | type = 'character',
24 | help = "where to save the anndata object?"),
25 | make_option(c("--assay"),
26 | action= "store",
27 | default = "RNA",
28 | type = 'character',
29 | help = "where to save the anndata object?"),
30 | make_option(c("--reduction"),
31 | action= "store",
32 | default = "umap",
33 | type = 'character',
34 | help = "where to save the anndata object?")
35 | )
36 |
37 | opt <- parse_args(OptionParser(option_list = option_list))
38 |
39 | cat("[INFO] Input parameters\n", file = stdout())
40 | for(user_input in names(opt)) {
41 | if(user_input=="help") next;
42 | cat(paste0("[INFO] ",user_input," => ",opt[[user_input]],"\n"),file = stdout())
43 | assign(user_input,opt[[user_input]])
44 | }
45 |
46 | cell_data <- readRDS(seurat_file)
47 |
48 | cell_data <- DietSeurat(
49 | cell_data,
50 | counts = TRUE,
51 | data = TRUE,
52 | scale.data = FALSE,
53 | features = NULL,
54 | assays = assay,
55 | dimreducs = reduction
56 | )
57 |
58 | cell_data <- as.SingleCellExperiment(cell_data)
59 |
60 | saveHDF5SummarizedExperiment(cell_data, dir = sce_folder,
61 | prefix = "", replace = FALSE,
62 | chunkdim = NULL, level = NULL, as.sparse = NA,
63 | verbose = NA)
64 |
--------------------------------------------------------------------------------
/st_snRNAseq/utils/spatial_plots_utils.R:
--------------------------------------------------------------------------------
1 | # Copyright (c) [2021] [Ricardo O. Ramirez Flores]
2 | # roramirezf@uni-heidelberg.de
3 |
4 | #' Utilities to generate ROI based on quadrants
5 |
6 |
7 | get_quadrant <- function(visium_slide, col_divisions = 4, row_divisions = 4, coord = c(1,1)) {
8 |
9 | # Extracting geometry
10 | geometry <- GetTissueCoordinates(visium_slide,
11 | cols = c("row", "col"), scale = NULL)
12 |
13 | row_min <- min(geometry$row)
14 | row_max <- max(geometry$row)
15 |
16 | row_length <- row_max - row_min
17 |
18 | col_min <- min(geometry$col)
19 | col_max <- max(geometry$col)
20 |
21 | col_length <- col_max - col_min
22 |
23 | # Make cut-offs
24 |
25 | row_cut <- ceiling(row_length/row_divisions)
26 | col_cut <- ceiling(col_length/col_divisions)
27 |
28 | # Now get conditionals
29 |
30 | row_max_cut <- (row_min + (row_cut * coord[1]))
31 | row_min_cut <- (row_min + (row_cut * (coord[1]-1)))
32 |
33 | col_max_cut <- (col_min + (col_cut * coord[2]))
34 | col_min_cut <- (col_min + (col_cut * (coord[2]-1)))
35 |
36 | # Filter cells by geometry
37 |
38 | ids <- geometry %>%
39 | as.data.frame() %>%
40 | rownames_to_column("spot_id") %>%
41 | filter((row >= row_min_cut) & (row <= row_max_cut),
42 | (col >= col_min_cut) & (col <= col_max_cut)) %>%
43 | pull(spot_id)
44 |
45 | #return cell_ids
46 |
47 | return(ids)
48 | }
49 |
50 |
51 |
52 |
53 |
--------------------------------------------------------------------------------