i have a file of 35k microarray rpboes aligned to a reference genome using STAR. It made a bam file containnig all the results. I want to know the gene_id on which the probes have aligned, how can i do that using bash or R
Assistant
User
i have a file of 35k microarray rpboes aligned to a reference genome using STAR. It made a bam file containnig all the results. I want to know the gene_id on which the probes have aligned, how can i do that using bash or R, i don't have bed file
Assistant
User
how to load makeblastdb and blastn modules
Assistant
To use and , you need to load the module first. Here’s how to do it in (Linux) or like , , or .
User
how to blast now that
i've installed dierectly without root
export PATH=PWD/ncbi−blast−2.17.0/bin:PATH
Assistant
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.
To find the gene IDs to which your microarray probes have aligned in your STAR-aligned BAM file, you'll need to map the probe sequences to your alignment results. Here's how you can do it both in Bash (using command-line tools) and in R.
Option 1: Using Bash (Samtools + Bedtools)
This approach assumes you have:
A BAM file (aligned.bam) from STAR.
A file (probes.bed) containing probe coordinates (or sequences) in BED format.
Step 1: Index the BAM file
bash
samtools index aligned.bam
Step 2: Extract alignments overlapping with probes
If you have probe coordinates in BED format (probes.bed):
bash
bedtools intersect -a aligned.bam -b probes.bed -wa -wb > probe_alignments.bed
This will give you a file where each line corresponds to an alignment overlapping a probe, including the probe ID and gene annotation.
If you only have probe sequences (not coordinates), you'll need to:
Align the probe sequences to the reference genome (e.g., using bowtie or bwa).
Then intersect with your BAM file.
Option 2: Using R (Rsamtools + GenomicFeatures)
This is more flexible if you have probe sequences or coordinates.
If your microarray has a known probe-to-gene mapping (e.g., Affymetrix, Illumina), you can directly use that instead of re-aligning.
For example:
r
library(affy)
probe_mapping <- get("hgu133plus2probe", "annotationData") # For Affymetrix arrays
Key Notes
If your probes are not in the BED file, you may need to BLAST them against the reference genome first.
For STAR-specific alignments, the NH tag in the BAM file indicates the number of alignments (useful for filtering multi-mapped probes).
Would you like help with any specific part of this workflow?
Since you don't have a BED file with probe coordinates but have a STAR-aligned BAM file and know the probe sequences, here’s how to map probes to genes in Bash or R.
Option 1: Using Bash (Samtools + BLAST)
If you have the probe sequences in a FASTA file (probes.fasta), you can:
Step 1: Extract aligned reads from the BAM file
bash
samtools view -h aligned.bam > aligned.sam
(Or use samtools fastq if you need FASTQ output.)
Step 2: BLAST probe sequences against the reference genome
bash
# Index the reference genome (if not already done)
makeblastdb -in reference_genome.fa -dbtype nucl
# BLAST probe sequences against the genome
blastn -query probes.fasta -db reference_genome.fa -out blast_results.txt -outfmt 6
-outfmt 6 gives tabular output (BLAST hits per probe).
Step 3: Extract gene IDs from BLAST hits
If your genome annotation is in GTF/GFF format, you can:
"Command not found": Ensure BLAST+ is installed/loaded.
"Database not found": Check -db path.
Low alignment scores: Try -task blastn-short for short sequences.
Would you like help with a specific step? 🚀
Since you've installed BLAST+ locally (without sudo) and set the PATH correctly, you can now use makeblastdb and blastn directly. Here’s a step-by-step guide to align your 35K microarray probes (FASTA file) to your reference genome:
1. Verify BLAST+ Installation
First, check that BLAST+ is working:
bash
blastn -version
You should see output like:
code
blastn: 2.17.0+
2. Create a BLAST Database from Your Reference Genome
Assuming your reference genome is in FASTA format (reference_genome.fa), run:
-dbtype nucl: For DNA sequences (prot for proteins).
-out: Output database name (e.g., my_blast_db).
Expected output:
code
Building a new DB, current time: 06/20/2024 12:00:00
New DB name: /path/to/my_blast_db
New DB title: reference_genome.fa
Sequence type: Nucleotide
Keep Linkouts: T
Keep MBits: T
Maximum file size: 1000000000B
Adding sequences from FASTA; added 100000 sequences in 4.53088 seconds.