# How to import data from cell ranger to R (Seurat)?

I will have some scRNA-seq data. The goal of the experiment will be to see if there is any difference in gene expression between treatment groups using the package Seurat from R.

I have read a tutorial how to do the analyze, but this tutorial does not explain how to import data. I am a total beginner with R, I searched the internet,but the majority of the explanations related to csv/excel/txt... common files. Data are from Cell ranger and spread in 3 files with following file extensions : .tsv and .mtx (barcodes.tsv, genes.tsv and matrix.mtx).

Collaborators ran Cell Ranger and gave these cell ranger output files : barcodes.tsv, genes.tsv and matrix.mtx.

Can someone give me the code to import these kind of data to R ?

Thank you in advance.

update: By "directory" you means "folder" on my computer for example ? So I need to save the 3 files under one folder and then to put name of the folder into brackets after the Read10x function ? I am a total beginner with R (I have used to R commander for statistical tests but that's it...).

update 2: I successed to import data into Seurat with the explanation of StupidWolf. I do not know C language ( I do not know almost any language ..). My system crashed a little further in the analyze after importing, not enough RAM... so now I am learning Linux commands to switch on the cluster.

Have a look here and the entire tutorial:

https://github.com/hbctraining/scRNA-seq/blob/master/lessons/03_SC_quality_control-setup.md

Answer from StupidWolf, converted from comment:

There is a function call Read10X in seurat, you can see how to use it with the example in https://support.10xgenomics.com/single-cell-gene-expression/software/pipelines/latest/rkit

You place the three files into a directory / folder, then you specify Read10X()... hey how big is your data? you might need to run this on a machine with enough RAM.

https://satijalab.org/seurat/v3.1/pbmc3k_tutorial.html

To convert data from one format into another, you may find some software tool sometimes. But mostly no such tool can be found to satisfy all the requirements that we want.

In such situations, I recommend that you write a C program that reads data from the input file and writes it into the output file. In this way, you have complete flexibility so that you can determine the exact output format and what part of data to ignore or include. To do that, you should be familiar with some concepts in C language such as arrays, loops, strings, and file operations.

For an example of such conversions, you can get ideas from the following page: https://stackoverflow.com/questions/55347322/c-program-to-convert-a-text-file-into-a-csv-file

Of course, such a converter program can be written in other languages too such as C# and Python.

The program can be developed in R language too. You need to be familiar with import functions, loops, strings, and arrays in this language.

We cannot expect that custom tools exist for all our file convertions. Every bioinformatician must be skilled in a standard programming language such as C, C#, Java, Python, or R. Then, he/she will be able to develop any custom program that reads an input file and generates a custom output file.

• It's a rather onerous workaround to write C programs as interfaces between R packages and data (R generally has excellent data import functionality). Apr 10 '20 at 16:58