<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Lok Raj Joshi on Medium]]></title>
        <description><![CDATA[Stories by Lok Raj Joshi on Medium]]></description>
        <link>https://medium.com/@lokrajvet?source=rss-d2a5f034738d------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*BwRYouJbmE1R1akU6Jq3XA.jpeg</url>
            <title>Stories by Lok Raj Joshi on Medium</title>
            <link>https://medium.com/@lokrajvet?source=rss-d2a5f034738d------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 30 Nov 2026 23:29:09 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@lokrajvet/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Working with the genome of non-model organism in R Bioconductor |]]></title>
            <link>https://medium.com/@lokrajvet/working-with-the-genome-of-non-model-organism-in-r-bioconductor-8c6eec253c8a?source=rss-d2a5f034738d------2</link>
            <guid isPermaLink="false">https://medium.com/p/8c6eec253c8a</guid>
            <category><![CDATA[bsgenome]]></category>
            <category><![CDATA[genomicfeatures]]></category>
            <category><![CDATA[r-bioconductor]]></category>
            <dc:creator><![CDATA[Lok Raj Joshi]]></dc:creator>
            <pubDate>Tue, 06 Aug 2019 02:13:14 GMT</pubDate>
            <atom:updated>2019-08-07T01:42:07.905Z</atom:updated>
            <content:encoded><![CDATA[<p>GenomicFeatures and BSgenome are two widely used packages for genomic data analysis in R Bioconductor. They have variety of functions to work with genome features. Unfortunately, there are only a limited species you can work with BSgenome. But, you can create Genome Features and BSgenome for your organism of choice if it is not packaged into BSgenome by default.</p><p>First let’s create a taxonomic database using GenomicFeatures package. I am using <a href="https://www.ncbi.nlm.nih.gov/nuccore/AY386263.1">Orf virus</a> as an example here .</p><p>First, download GFF3 file of the Orf virus from the Genebank. For some reason the GFF3 file downloaded from Genebank has to be modified using some awk commands. You can find the script <a href="https://www.biostars.org/p/382165/">here</a>. I want to acknowlege <a href="https://www.biostars.org/u/33094/">SMK</a> for this solution.</p><p>After you convert your GFF3 file into new GFF3 format and save it as orf.gff3. Then it is pretty straightforward to create taxonomic database.</p><pre>library (GenomicFeatures) orf &lt;- orf &lt;- GenomicFeatures::makeTxDbFromGFF(&quot;orf.gff3&quot;,format=&quot;auto&quot;) orf</pre><p>Then you have to save this database,so that you can call it in future without recreating it again. We will use saveDb() to save database and loadDb() to load the database. We can use AnnotationDbi package fot this purpose. You will see a new file as orf in the working directory.</p><pre>library (AnnotationDbi) saveDb(orf,&quot;orf&quot;)</pre><p>As you can see we just created a taxonomic database for Orf virus. There are 130 CDS that have been extracted and you can use other functions as shown below.</p><p>First load the database and then try different funtions.</p><pre>library (AnnotationDbi) orf &lt;- loadDb(file=&quot;orf&quot;) columns(orf)</pre><pre>intergenic &lt;- gaps (genes) </pre><pre>head (intergenic)</pre><p>So, you can extract anything from this genome. Look at the columnames to see what kind of information you can extract.</p><p>This taxonomic database shows the postions where each gene or features are located within the genome. It does not actually contain any DNA sequence. To extract DNA sequence we need BSgenome package. Unfortunately, this virus or other viruses are not included in BSgenome package but the package allows you to make your own pakcage. This process is kown as “forging”. So, lets try to forge BSgenome for our Orf virus, so that we can work with DNA sequence of this virus.</p><p>This process involves a creating a src file that contains all the information about the genome. We will need fasta file of the genome, finally we will use command line tools to create a package. So, we will be creating a BSgenome package for Orf virus.</p><p>Steps :</p><p>First create a folder named Orf.</p><p>Inside that folder create a folder called src_seqdir.</p><p>Put your genome in fasta format inside that folder.</p><p>Create a plain text file and keep following information.Change the parameters as you like or that makes sense according to the genome that you are working with.</p><p>Package: OrfTxdb</p><p>Title: Full genome of Orf Virus Strain IA82</p><p>Description: Full genome of orf virus</p><p>Version: 1.0.0</p><p>Suggests: Orf.virus.NCBI</p><p>organism: Orfv</p><p>Author: Delhon et al.</p><p>common_name: Orf virus</p><p>provider: NCBI</p><p>provider_version: 1.0.0</p><p>release_date: Jan.2004</p><p>release_name: Orf virus strain OV-IA82</p><p>BSgenomeObjname: Orfv virus</p><p>source_url: <a href="https://www.ncbi.nlm.nih.gov/nuccore/AY386263.1">https://www.ncbi.nlm.nih.gov/nuccore/AY386263.1</a></p><p>organism_biocview: AnnotationData, BSgenome</p><p>seqnames: c(“orfv”)</p><p>SrcDataFiles: orfv.fasta</p><p>seqfiles_suffix: .fasta</p><p>seqs_srcdir: C:_000</p><p>Then save this plain text file as seed_file.txt. Remember the package name. This will be the name of your package.</p><p>Convert this plain file into DCF format in R. First read the file and then save it as DCF format.</p><pre>my_file &lt;- read.dcf(&quot;seed_file.txt&quot;, fields = NULL, all = FALSE, keep.white = NULL) </pre><pre><br>write.dcf(my_file , file = &quot;seed.dcf&quot;, append = FALSE, useBytes = FALSE, indent = 0.1 * getOption(&quot;width&quot;), width = 0.9 * getOption(&quot;width&quot;), keep.white = NULL)</pre><p>We will get seed.dcf file as an output. Now we are ready to forge.</p><pre>library (BSgenome) </pre><pre>unlink(c(&quot;OrfTxdb&quot;), recursive = TRUE, force = TRUE) </pre><pre>forgeBSgenomeDataPkg(&quot;seed.dcf&quot;)</pre><p>It will create a new directory in the current directory. The name will be ORfTxdb as we supplied this name on the seed file.</p><p>Now we are ready to create package.</p><p>Go to the Terminal of the R Studio and navigate to the current folder. Enter following command</p><p>R CMD build OrfTxdb</p><p>Enter the name of the folder that was created above when by forgeBSgenomeDataPkg function. This will create a tarball file of our package.In my case a new tar file called OrfTxdb_1.0.0.tar was created.</p><p>Check if everything is okay with your package using following command in the terminal</p><p>R CMD check OrfTxdb_1.0.0.tar</p><p>If everything is correct, then install the package using follwing command:</p><p>R CMD install OrfTxdb_1.0.0.tar</p><p>Now you can go back to R studio console and call this package. For example I names my package as OrfTxdb &#39;. Lets use some functions on this package :</p><pre>library (OrfTxdb) orf_genome &lt;- OrfTxdb orf_genome</pre><pre>organism(orf_genome)</pre><pre>provider(orf_genome)</pre><pre>getSeq(orf_genome,start=24,end=58)</pre><p>So, there are other cool things that can be done using genome features and BSgenome. For example, we can get postions of all the promoter sequences from genome features and use those values to extract promoter sequences from the BSgenome. I will write a post how to do that, but there are already tutorials available. For now, if we want to get the files and folders used in this tutorial you can get them here in my <a href="https://github.com/lrjoshi/OrfTxdb">Github</a>.</p><p><em>Originally published at </em><a href="https://lokraj.me/2019/08/05/working-with-the-genome-of-non-model-organism-in-r-bioconductor/"><em>https://lokraj.me</em></a><em> on August 6, 2019.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8c6eec253c8a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Download CSV fiinto R Studio from Github]]></title>
            <link>https://medium.com/@lokrajvet/download-csv-fiinto-r-studio-from-github-9ec197cdc096?source=rss-d2a5f034738d------2</link>
            <guid isPermaLink="false">https://medium.com/p/9ec197cdc096</guid>
            <category><![CDATA[r]]></category>
            <category><![CDATA[excel-and-csv-files]]></category>
            <category><![CDATA[terminal]]></category>
            <dc:creator><![CDATA[Lok Raj Joshi]]></dc:creator>
            <pubDate>Thu, 10 Jan 2019 02:13:14 GMT</pubDate>
            <atom:updated>2019-08-07T01:36:26.140Z</atom:updated>
            <content:encoded><![CDATA[<h3>Download CSV files into R Studio from Github</h3><p>Steps</p><ol><li>Go to the github repository link where you have the CSV file</li><li>Click on the <strong>raw</strong> option present on the top right of the data</li><li>This will open a new window in the browser</li><li>The link should be like <a href="https://raw.githubusercontent.com/">https://raw.githubusercontent.com/..</a></li><li>You have to use this link to download csv file from the Github</li></ol><pre>urlfile=&quot;https://raw.githubusercontent.com/lrjoshi/webpage/master/public/post/c159s.csv&quot; mydata&lt;-read_csv(url(https://medium.com/urlfile))</pre><p>You can use this method to dowload R data file from the github.</p><p><em>Originally published at </em><a href="https://lokraj.me/2019/01/09/download-csv-into-r-studio-from-github/"><em>https://lokraj.me</em></a><em> on January 10, 2019.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9ec197cdc096" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[RNA-Seq Data Analysis in R]]></title>
            <link>https://medium.com/@lokrajvet/rna-seq-data-analysis-in-r-927907833ea9?source=rss-d2a5f034738d------2</link>
            <guid isPermaLink="false">https://medium.com/p/927907833ea9</guid>
            <category><![CDATA[r]]></category>
            <category><![CDATA[zika-virus]]></category>
            <category><![CDATA[rna-seq]]></category>
            <dc:creator><![CDATA[Lok Raj Joshi]]></dc:creator>
            <pubDate>Sun, 20 May 2018 04:00:00 GMT</pubDate>
            <atom:updated>2019-08-07T01:38:28.603Z</atom:updated>
            <content:encoded><![CDATA[<p>RNA-Seq data analysis can be complicated. Softwares with graphical user interface like CLC Workbench, have made RNA-Seq data analysis quite easier.However, they are expensive and in most of the cases you might not be able to tweak your analysis in the exact way you want. Another important aspect of learning RNA-Seq analysis is understanding the algorithms behind the analysis.To this end, I decided to run a small simulation to understand how RNA-Seq analysis algorithms work.It is amazing how a single R package can do things like read aligning, read mapping and read counts in few lines of codes.</p><p>Install Rsubread package in R.</p><pre>source(&quot;https://bioconductor.org/biocLite.R&quot;) biocLite(&quot;Rsubread&quot;)</pre><p>Load package</p><p>library (Rsubread)</p><p>For this simulation I created a small .fasta file by pulling some of the sequences from the <strong>Senecavirus A</strong> genome. I created a fasta file with a few contigs each containing about 70–100 basepairs , and named each contig as read 1, read 2 and so on. And I also pulled some sequences from the Zika virus which are names as Zika1 and Zika2. I will be aligning my reads to Senecavirus A genome. So, Zika virus reads should not be counted by Rsubread while aligning.</p><p>Sequences extracted:</p><pre>read1 AAGGAAGGACTGGGCATGAGGGCCCAGTCCTTCCTTTCCCCTTCCGGGGGGTAAACCGGCTGTGTTTGCT read2 AGAGGCACAGAGGAGCAACATCCAACCTGCTTTTGTGGGGAACGGTGCGGCTCCAATTCCTGCGTCGCCA read3 AAGGTGTTAGCGCACCCAAACGGCGCATCTACCAATGCTATTGGTGTGGTCTGCGAGTTCTAGCCTACTC read4 GTTTCTCCCCTACTCACTCATTCACACACAAAAACTGTGTTGTAACTACAAGATTTGGCCCTCGCACGGG read5 ATGTGCGATAACCGCAAGATTGACTCAAGCGCGGAAAGCGCTGTAACCACATGCTGTTAGTCCCTTTATG readagain1 AAGGAAGGACTGGGCATGAGGGCCCAGTCCTTCCTTTCCCCTTCCGGGGGGTAAACCGGCTGTGTTTGCT readagain2 AGAGGCACAGAGGAGCAACATCCAACCTGCTTTTGTGGGGAACGGTGCGGCTCCAATTCCTGCGTCGCCA readagain3 GTTTCTCCCCTACTCACTCATTCACACACAAAAACTGTGTTGTAACTACAAGATTTGGCCCTCGCACGGG read12 CGGGGGGTAAACCGGCTGTGTTTGCTAGAGGCACAGAGGAGCAACATCCAACCTGCTTTTGT read23 CGGCTCCAATTCCTGCGTCGCCAAAGGTGTTAGCGCACCCAA read34 GTGTGGTCTGCGAGTTCTAGCCTACTCGTTTCTCCCCTACTCACTCATTCACACACAAAAA read45 CTACAAGATTTGGCCCTCGCACGGGATGTGCGATAACCGCAAGATTGACTCAAGCGCGGAAAGCGCTGTAACC readsvalast TGCCGTACCGAGTCACGAGTACCTGCAGGCAAGATGGAGGGCCTTGTTCGACTGACCTGGATAGCCCAACGCGCTTCGGTGCTGCCGGCGATTCTGGGAGAACTCAGTCGGA readagain1 AAGGAAGGACTGGGCATGAGGGCCCAGTCCTTCCTTTCCCCTTCCGGGGGGTAAACCGGCTGTGTTTGCT zika1 AGTTGTTGATCTGTGTGAATCAGACTGCGACAGTTCGAGTTTGAAGCGAAAGCTAGCAACAGTATCAACA zika12 AAAGCTAGCAACAGTATCAACAGGTTTTATTTTGGATTTGGAAACGAGAGTTTCTGGTCATGAAAAACCCA</pre><p>This fasta file needs to be changed into <strong>fastq</strong> format. There are many tools available to convert fasta file to fastq format. I used <strong>reformat.sh</strong> script which is a part of <strong>bbmap</strong>. You can find details about bbmap and reformat.sh script elsewhere. The general syntax is as follow:</p><pre>./reformat.sh in= meta.fasta out=meta.fastq qfake=35</pre><p>Now, lets go back to R. We have loaded our package already. First, we need to build index of our reference files. Use the same Senecavirus A whole genome file which you used to extract reads in the above example. The file can be in fasta format. Then run follwing command.</p><pre>buildindex(basename=&quot;reference_index&quot;,reference=ref)</pre><p>In my case it would be</p><pre>buildindex(basename= &quot;seneca&quot;, reference= &quot;sva.fasta&quot;)</pre><p>Now, I can align reads in <strong>meta.fastq</strong> to the index file which I created above.</p><pre>align(index=&quot;seneca&quot;,readfile1=&quot;meta.fastq&quot;,output_file=&quot;alignResults.BAM&quot;)</pre><p>I saw that all the reads that were in meta.fastq belonging to Senecavirus A were aligned while , all the Zika virus reads were ignored.The output will be in .BAM format.</p><p>Now the tricky part. We need a annotated file in GTF or GFF format to count the features or genes aligned. For viruses, in most of the cases you don’t find well-annotated GTF or GFF files. Rsubread package allows you to create such files in tabular format which they call it SAF format.</p><p>So, lets use follwing code to create one SAF file for this analysis.</p><pre>ann &lt;- data.frame( GeneID=c(&quot;gene1&quot;,&quot;gene1&quot;,&quot;gene2&quot;,&quot;gene2&quot;), Chr=&quot;KX778101.1&quot;, Start=c(100,1000,3000,5000), End=c(500,1800,4000,5500), Strand=c(&quot;+&quot;,&quot;+&quot;,&quot;-&quot;,&quot;-&quot;), stringsAsFactors=FALSE)</pre><p>Here you have to use Genebank accession number of virus genome as Chr. Beacuse .BAM file that we created by aligning to Senecavirus A genome have accession number liked to each reads. Other parameters can be changed.</p><p>Now, final step is to count reads.</p><pre>fc_SE &lt;- featureCounts(&quot;alignResults.BAM&quot;,annot.ext=ann) fc_SE</pre><p>You can see how many features were counted on the basis of information you provided in SAF table. You will see all the sequences that we extracted from the Senecavirus A genome have been been counted while there will not be any counts for Zika virus sequences.</p><p>Hope this will help you to understand how Rsubread package works. If you have any confusion about using Rsubread package, they have very good documentation on Bioconductor.</p><p><em>Originally published at </em><a href="https://lokraj.me/2018/05/20/rna-seq-data-analysis-in-r/"><em>https://lokraj.me</em></a><em> on May 20, 2018.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=927907833ea9" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>