Entering edit mode
4.0 years ago
Bioinfonext
▴
470
Hi, Now jupyter installed on the server and I am using below code to plot the rarefaction plot but I am still getting some error. could you please suggest how I can get rid of it?
#!/bin/bash
#SBATCH --job-name=plot # Job name
#SBATCH --nodes=3 # Number of nodes
#SBATCH --time=2000:00:00 # Time limit hrs:min:sec
#SBATCH --partition=k2-lowpri
#SBATCH --mem=150G
module load apps/jupyter/4.6.3
module load libs/pandas/0.24.2/gcc-4.8.5+python-2.7.8+setuptools-39.2.0+numpy-1.16.2
module load apps/python3/3.7.4/gcc-4.8.5
module load apps/qiime2/2019.4.0/bin
module load libs/matplotlib_python34/1.5.1/gcc-4.8.5+python3-3.4.3+numpy_python34-1.11.3
#Run it in jupyter lab or notebook
import seaborn as sns
import matplotlib.pyplot as plt
import pandas as pd
%matplotlib inline
qza = 'alpha-rarefaction-20000.qzv' # path to rarefaction file from qiime2
a = !unzip $qza
digest = a[1].split('/')[0].replace(' inflating: ','')
inf = digest + '/data/observed_otus.csv'
otus = pd.read_csv(inf,index_col=0, sep=',')
!rm -r $digest
cols = [col for col in otus.columns if 'iter' not in col]
mean,data = otus[cols],pd.DataFrame(columns=cols)
depths = [col.split('_')[0] for col in otus.columns if 'depth' in col]
otus = otus.drop(cols,axis=1)
otus.columns = depths
for depth in depths:
mean['ASV'] = otus[depth].mean(axis=1)
mean['depth']= depth.split('-')[-1]
data = pd.concat([data,mean])
# here provide colors for each item that will be plotted
pal={'Irrigated':'brown','Rainfed':'red'}
fig,ax = plt.subplots(figsize=(2.5,2),dpi=600,tight_layout=True)
sns.set(style='ticks',rc={"lines.linewidth":0.7,"axes.linewidth":0.5})
# use your column name to plot here instead of 'BodySite'
sns.lineplot(x='depth',y='ASV',data=data,palette=pal,hue='Season',sort=False,err_style='bars',\
dashes=True,style='Season',ci=67)
ax.set_xlabel('Sequencing depth',fontsize=8)
ax.set_ylabel('Observed ASVs',fontsize=8)
ax.tick_params(axis='x', labelrotation=90)
ax.tick_params(axis='both',which='major',length=2,pad=0.5,labelsize=6)
handles, labels = ax.get_legend_handles_labels()
ax.legend(handles=handles[1:],labels=labels[1:],fontsize=5,frameon=False,numpoints=4,borderaxespad=0,handletextpad=0.2,loc=2,)
plt.savefig('Infected_observed_ASVs.png', bbox_inches='tight')
Error;
import: unable to open X server `' @ error/import.c/ImportImageCommand/344.
import: unable to open X server `' @ error/import.c/ImportImageCommand/344.
import: unable to open X server `' @ error/import.c/ImportImageCommand/344.
/var/spool/slurmd.spool/job1452532/slurm_script: line 21: fg: no job control
/var/spool/slurmd.spool/job1452532/slurm_script: line 23: qza: command not found
/var/spool/slurmd.spool/job1452532/slurm_script: line 24: a: command not found
/var/spool/slurmd.spool/job1452532/slurm_script: line 25: syntax error near unexpected token `('
/var/spool/slurmd.spool/job1452532/slurm_script: line 25: `digest = a[1].split('/')[0].replace(' inflating: ','')'
metadata file ;
#SampleID Villages Region Treatment Batch Season
PN0086D.1.S1 Kholabari Mymensingh T1 batch1 Irrigated
PN0086D.2.S2 Bogajan Mymensingh T1 batch1 Irrigated
PN0086D.3.S3 Bonkua Mymensingh T1 batch1 Irrigated
If you are running this as a SLURM job it looks like your shell is trying to run the code instead of
python
(https://unix.stackexchange.com/questions/240702/import-unable-to-open-x-server-error-import-c-importimagecommand-361 ).now it says invalid syntax, but if I load jupyter module on terminal then it do not show any error.
error
Script; I am running script like this; sbatch rarefaction.plot.jypiter.sh