<p>I want to analyse the single-cell ATAC-seq data from 10X downloaded from GSE158398. The files attached to this dataset are <code>matrix.mtx.gz</code>, <code>fragments.tsv.gz</code>, and <code>barcodes.tsv.gz</code> files, in addition to a <code>peaks.bed.gz</code> file.</p>
<p>How do I load this into R and make a Seurat object? Normally there is a matrix, barcodes and features files as output from scATAC-seq 10X data, so how do I handle only having a fragments file instead?</p>
<p>Thank you very much for your help with this!</p>
<p>Edit:</p>
<p>This is the code I would normally run to load the ATAC counts (matrix), barcodes and features and make the Seurat object. However, with this dataset, I do not have the features.tsv file, but a fragments.tsv file instead and so I am unsure how to change my code to accommodate this change in input data.</p>
<pre class="lang-r prettyprint-override"><code>ATAC_dir &lt;- &quot;~/GSE169246_PDL1/ATAC/&quot;

barcode_path_ATAC &lt;- paste0(ATAC_dir, &quot;barcodes.tsv.gz&quot;)
features_path_ATAC &lt;- paste0(ATAC_dir, &quot;features.tsv.gz&quot;)
matrix_path_ATAC &lt;- paste0(ATAC_dir, &quot;matrix.mtx.gz&quot;)

barcode_names_ATAC &lt;- read.delim(barcode_path_ATAC, 
                            header = FALSE, 
                            stringsAsFactors = FALSE)$V1

feature_names_ATAC &lt;- read.delim(features_path_ATAC, 
                                 header = FALSE, 
                                 stringsAsFactors = FALSE)$V1

mat_ATAC &lt;- readMM(file = matrix_path_ATAC)

colnames(mat_ATAC) &lt;- barcode_names_ATAC
rownames(mat_ATAC) &lt;- feature_names_ATAC


chrom_assay &lt;- CreateChromatinAssay(
  counts = mat_ATAC,
  sep = c(&quot;:&quot;, &quot;-&quot;),
  genome = 'hg38',
  fragments = &quot;peaks.bed.gz&quot;,
  min.cells = 10,
  min.features = 200
)

seurat_ATAC &lt;- CreateSeuratObject(
  counts = chrom_assay,
  assay = &quot;peaks&quot;
)
</code></pre>

CC BY-SA 4.0
2023-06-22T14:32:34.783Z
Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking.
Community
CC BY-SA 4.0
2023-06-22T14:43:22.650Z
Welcome to the site Ebla. Could you kindly describe the code you have written so far to load the data?
M__
CC BY-SA 4.0
2023-06-23T07:17:04.943Z
Thank you, I have edited my original post now. I hope it is more clear now, please let me know if I can make it clearer
Embla
<seurat><single-cell><10x-genomics><atac-seq>
Loading scATAC-seq data containing matrix.mtx, fragments.tsv and barcodes.tsv files from GEO into R?
# Loading scATAC-seq data containing matrix.mtx, fragments.tsv and barcodes.tsv files from GEO into R?

(Asked by: username_0 on 2023-06-22)

I want to analyse the single-cell ATAC-seq data from 10X downloaded from GSE158398. The files attached to this dataset are matrix.mtx.gz, fragments.tsv.gz, and barcodes.tsv.gz files, in addition to a peaks.bed.gz file.
How do I load this into R and make a Seurat object? Normally there is a matrix, barcodes and features files as output from scATAC-seq 10X data, so how do I handle only having a fragments file instead?
Thank you very much for your help with this!
Edit:
This is the code I would normally run to load the ATAC counts (matrix), barcodes and features and make the Seurat object. However, with this dataset, I do not have the features.tsv file, but a fragments.tsv file instead and so I am unsure how to change my code to accommodate this change in input data.
ATAC_dir <- "~/GSE169246_PDL1/ATAC/"

barcode_path_ATAC <- paste0(ATAC_dir, "barcodes.tsv.gz")
features_path_ATAC <- paste0(ATAC_dir, "features.tsv.gz")
matrix_path_ATAC <- paste0(ATAC_dir, "matrix.mtx.gz")

barcode_names_ATAC <- read.delim(barcode_path_ATAC, 
                            header = FALSE, 
                            stringsAsFactors = FALSE)$V1

feature_names_ATAC <- read.delim(features_path_ATAC, 
                                 header = FALSE, 
                                 stringsAsFactors = FALSE)$V1

mat_ATAC <- readMM(file = matrix_path_ATAC)

colnames(mat_ATAC) <- barcode_names_ATAC
rownames(mat_ATAC) <- feature_names_ATAC


chrom_assay <- CreateChromatinAssay(
  counts = mat_ATAC,
  sep = c(":", "-"),
  genome = 'hg38',
  fragments = "peaks.bed.gz",
  min.cells = 10,
  min.features = 200
)

seurat_ATAC <- CreateSeuratObject(
  counts = chrom_assay,
  assay = "peaks"
)

**Tags:** seurat, single-cell, 10x-genomics, atac-seq
> **Comments:**
> **username_1**: Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking.  
> **username_2**: Welcome to the site Ebla. Could you kindly describe the code you have written so far to load the data?  
> **username_0**: Thank you, I have edited my original post now. I hope it is more clear now, please let me know if I can make it clearer  

---

## 0 answers

